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 nvm install error if /sbin/init is absent and errtrace is enabled #2698

Merged
merged 3 commits into from Dec 27, 2021
Merged

Fix nvm install error if /sbin/init is absent and errtrace is enabled #2698

merged 3 commits into from Dec 27, 2021

Conversation

lkrms
Copy link
Contributor

@lkrms lkrms commented Dec 26, 2021

(Discussed at length in #2678)

  • Move ls -dl /sbin/init to the following if statement for implicit
    error handling (even if enabled, errexit and errtrace have no
    effect in this context)
  • Disable errtrace (set -E) in nvm_get_arch and consolidate existing
    checks for set -e and set -a into one loop

nvm install fails with "Binary download failed, trying source" in Arch
Linux package build scripts. This is the combined result of makepkg
running these scripts with ERR trap inheritance enabled, and the lack
of error handling when nvm_get_arch calls ls -dl /sbin/init. If
/sbin/init doesn't exist, the ERR trap set by makepkg exits
non-zero and the operation fails.

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 have some tests that cover these changes, and it'd also be great to split the two changes into separate commits.

nvm.sh Outdated Show resolved Hide resolved
nvm.sh Outdated Show resolved Hide resolved
@lkrms
Copy link
Contributor Author

lkrms commented Dec 26, 2021

I haven't added any tests yet, but I've made the changes we discussed and they don't seem to break anything 🤞🏻

nvm.sh Outdated Show resolved Hide resolved
nvm.sh Outdated Show resolved Hide resolved
nvm.sh Outdated Show resolved Hide resolved
`nvm install` fails with "Binary download failed, trying source" when
- running on Bash;
- errtrace (`set -E`) is enabled;
- an ERR trap uses `exit` to return a non-zero status; and
- /sbin/init doesn't exist.

Resolved by moving `ls -dl /sbin/init` to the following `if` statement.
In this context, returning non-zero isn't an error and the ERR trap
isn't executed.
@lkrms
Copy link
Contributor Author

lkrms commented Dec 27, 2021

I've added a test that fails under the conditions we've established are problematic unless one or both of the subsequent commits are merged.

Let me know if there's anything else you need :)

@ljharb ljharb merged commit 1875fe8 into nvm-sh:master Dec 27, 2021
@lkrms lkrms deleted the fix/nvm-install-with-bash-errtrace branch December 28, 2021 00:10
@lkrms
Copy link
Contributor Author

lkrms commented Jun 13, 2022

Thanks for merging this back in December, @ljharb :)

I hope it's okay to ask here if a new release is imminent? In CI contexts, at least, workarounds for this bug are still necessary until an nvm release is made and downstream packages pick it up.

🙏🏻

@ljharb
Copy link
Member

ljharb commented Jun 13, 2022

Unfortunately tests are broken, so merges and releases are blocked on #2802.

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.

None yet

2 participants