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

Conversation

tim-mit
Copy link

@tim-mit tim-mit commented Aug 27, 2023

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 #3034

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
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

it'd be great to add this to the nvm_supports_xz unit tests - we'd have to mock out nvm_get_os to be darwin, and then put a tar on the path whose --version output matched gnu tar's, and make sure there's no xz on the path, and then we could assert it returns 1?

@@ -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

@ljharb ljharb marked this pull request as draft October 30, 2023 19:27
@ljharb
Copy link
Member

ljharb commented Oct 30, 2023

@tim-mit are you still interested in completing this PR?

@ljharb ljharb force-pushed the master branch 2 times, most recently from c6cfc3a to c20db2a Compare June 10, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tar (child): xz: Cannot exec: No such file or directory on brew gnu tar
2 participants