Skip to content

Commit b42c165

Browse files
committed
[Fix] gracefully handle GNU tar on MacOS during nvm install
GNU tar doesn't support using the -J flag required to unpack xz-compressed tarballs when xv isn't installed. Check for this scenario and fallback to using gzip-compressed tarballs. Fixes nvm-sh#3034
1 parent c92adb3 commit b42c165

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nvm.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -4325,7 +4325,11 @@ nvm_supports_xz() {
43254325
if [ "_${NVM_OS}" = '_darwin' ]; then
43264326
local MACOS_VERSION
43274327
MACOS_VERSION="$(sw_vers -productVersion)"
4328-
if nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
4328+
if tar --version | command grep -q GNU && ! command which xz >/dev/null 2>&1; then
4329+
# On macOS with GNU tar in use, and no xv on the path, xv-compressed
4330+
# tarballs aren't supported
4331+
return 1
4332+
elif nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
43294333
# macOS 10.8 and earlier doesn't support extracting xz-compressed tarballs with tar
43304334
return 1
43314335
fi

0 commit comments

Comments
 (0)