-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Fix nvm install
error if /sbin/init is absent and errtrace is enabled
#2698
Conversation
There was a problem hiding this 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.
I haven't added any tests yet, but I've made the changes we discussed and they don't seem to break anything 🤞🏻 |
`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.
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 :) |
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. 🙏🏻 |
Unfortunately tests are broken, so merges and releases are blocked on #2802. |
(Discussed at length in #2678)
ls -dl /sbin/init
to the followingif
statement for impliciterror handling (even if enabled,
errexit
anderrtrace
have noeffect in this context)
set -E
) in nvm_get_arch and consolidate existingchecks for
set -e
andset -a
into one loopnvm install
fails with "Binary download failed, trying source" in ArchLinux 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
callsls -dl /sbin/init
. If/sbin/init
doesn't exist, the ERR trap set bymakepkg
exitsnon-zero and the operation fails.