Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] gracefully handle GNU tar on MacOS during nvm install #3178

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4325,7 +4325,11 @@ 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 && ! command which xz >/dev/null 2>&1; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if tar --version | command grep -q GNU && ! command which xz >/dev/null 2>&1; then
if command tar --version | command grep -q GNU && ! command which xz >/dev/null 2>&1; then

# On macOS with GNU tar in use, and no xv on the path, 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