Skip to content

Commit

Permalink
[Fix] gracefully handle GNU tar on MacOS during npm install
Browse files Browse the repository at this point in the history
GNU tar doesn't support using the -J flag required to unpack
xz-compressed tarballs. This change means that anyone using
GNU tar on MacOS will instead use gz-compressed tarballs.

Fixes nvm-sh#3034
  • Loading branch information
tim-mit committed Aug 22, 2023
1 parent c92adb3 commit 2b32281
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4325,7 +4325,10 @@ nvm_supports_xz() {
if [ "_${NVM_OS}" = '_darwin' ]; then
local MACOS_VERSION
MACOS_VERSION="$(sw_vers -productVersion)"
if nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
if tar --version | command grep -q GNU; then
# On macOS with GNU tar in use xv-compressed tarballs aren't supported
return 1
elif nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
# macOS 10.8 and earlier doesn't support extracting xz-compressed tarballs with tar
return 1
fi
Expand Down

0 comments on commit 2b32281

Please sign in to comment.