-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
As of 0.24.1, bash -e
option causes failures
#721
Comments
Do you perhaps have your deploy script set up to exit whenever any function exits nonzero? If so, that's likely to be the problem, as a nonzero exit code is being used here intentionally. |
+1 This causes our CI to fail, since we're running scripts with |
Yes, that's going to continue to be a problem. Running with You could always |
See nvm-sh/nvm#721. NVM expects us to not terminate even if it produces non-zero exit codes.
@ljharb yes, RightScale aborts on non-zero exit codes. I will try the |
@ljharb Using #!/bin/bash -x
# install node version manager
echo "installing node version manager..."
git clone https://github.com/creationix/nvm.git $E_NVM_DIR
cd $E_NVM_DIR
git checkout `git describe --abbrev=0 --tags`
. $E_NVM_DIR/nvm.sh
set -e
if [ -z ${NVM_DIR+x} ] ; then
echo "Unable to source nvm."
exit 1
fi |
-e
option causes failures
Just spent a few hours figuring out why packer was returning exit code 2 when trying to install nvm and finally traced it down to this issue. It would be nice if anything that cared about exit codes didn't break just because there isn't an alias for default installed yet. Especially if the next thing you're going to do is install a default next... Is there a way to source nvm.sh without having it immediately try to use a version of nvm? Could there just be another |
@fastest963 no, I'm afraid not - I'd be open to a PR adding that as an option (like However, on re-reviewing this issue, it seems like perhaps it's simply that https://github.com/creationix/nvm/blob/master/nvm.sh#L1787 doesn't always return |
FYI, We resolved this in our scripts, by creating https://github.com/ropez/nvx and using that instead of nvm. |
@ljharb I tried --- a/nvm.sh
+++ b/nvm.sh
@@ -1795,6 +1795,8 @@ elif [ -n "$VERSION" ]; then
nvm use "$VERSION" >/dev/null
elif nvm_rc_version >/dev/null 2>&1; then
nvm use >/dev/null
+else
+ return 0
fi
} # this ensures the entire script is downloaded # [vagrant@localhost ~]$ source ~/.nvm/nvm.sh; echo $?
0 |
Great, I'll add that tonight then once I can add a test for it. |
@fastest963 hm, I can't reproduce the failing exit code. If you just comment out the entire if/else block, does it fail with the same code it failed with before? |
@ljharb Ah... so it appears that when So actually something like: --- a/nvm.sh
+++ b/nvm.sh
@@ -1784,7 +1784,7 @@ nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes 2> /dev/null)" = "_yes" ]
}
-VERSION="$(nvm_alias default 2>/dev/null)"
+VERSION="$(nvm_alias default 2>/dev/null || echo)"
if nvm_supports_source_options && [ "_$1" = "_--install" ]; then
if [ -n "$VERSION" ]; then
nvm install "$VERSION" >/dev/null The Tested with: #!/bin/bash
set -e
source ~/.nvm/nvm.sh
echo "worked" Prints |
Awesome! Thanks @ljharb 👍 |
Released in |
NOTE I'm still investigating this and it sounds like it might be an edge case, but I'm opening the issue now with the information I have in case others are experiencing this.
We use RightScale to deploy virtual servers. Today our instances, which all install nvm when launched, all started failing. We traced the audit output (shown below) to the nvm.sh script:
The install script that generates this audit output looks like this (
E_NVM_DIR=/opt/nvm
):We changed the git checkout line to read:
and the images are all launching successfully now. So something in the v0.24.1 release, seemingly around automatic default version assignment, seems to be affecting our images. We are running Ubuntu 12.04.1 LTS with bash.
The text was updated successfully, but these errors were encountered: