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

No longer supports set -e #1130

Open
alistairjcbrown opened this issue Jun 28, 2016 · 6 comments
Open

No longer supports set -e #1130

alistairjcbrown opened this issue Jun 28, 2016 · 6 comments

Comments

@alistairjcbrown
Copy link

alistairjcbrown commented Jun 28, 2016

I have a script with set -e set to allow it to bail if there's an error, but with exceptions within. In this script, the NVM sourcing is under set +e and the nvm install is under set -e again (see test script below).

When running nvm install, a cryptic error of "No such file or directory" is output. It appears that nvm_version_path is returning empty, which is causing the error.

Found '/path/to/project/.nvmrc' with version <v6.2.2>
Downloading https://nodejs.org/dist/v6.2.2/node-v6.2.2-darwin-x64.tar.xz...
######################################################################## 100.0%
mkdir: : No such file or directory
Binary download failed, trying source.
######################################################################## 100.0%
Checksums empty
mkdir: : No such file or directory
Binary download failed, trying source.

This was not an issue with v0.29.0 (nor it seems v0.30.0, v0.30.1 or v0.31.0), but appears to be an issue since v0.31.1. A small test file to recreate:

#!/bin/sh
set -e

set +e
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
set -e

nvm install 6.2.2

With version v0.29.0

> $ nvm --version
0.29.0
> $ ./test.sh
Downloading https://nodejs.org/dist/v6.2.2/node-v6.2.2-darwin-x64.tar.xz...
######################################################################## 100.0%
WARNING: checksums are currently disabled for node.js v4.0 and later
Now using node v6.2.2 (npm v3.9.5)

With version v0.31.1

> $ nvm --version
0.31.1
> $ ./test.sh
N/A: version "v6.2.0" is not yet installed
Downloading https://nodejs.org/dist/v6.2.2/node-v6.2.2-darwin-x64.tar.xz...
######################################################################## 100.0%
mkdir: : No such file or directory
Binary download failed, trying source.
######################################################################## 100.0%
Checksums empty
mkdir: : No such file or directory
Binary download failed, trying source.
Detected that you have 8 CPU thread(s)
Set the number of jobs to 8 - 1 = 7 jobs to speed up the build
Installing node v1.0 and greater from source is not currently supported
@alistairjcbrown
Copy link
Author

Looking at the release notes for v0.31.1, I wonder if this is related:

set -e: ensure nvm_version returning 3, and nvm_alias returning 2, doesn’t terminate the process

@ljharb
Copy link
Member

ljharb commented Jun 28, 2016

@alistairjcbrown can you try with v0.31.2? If there's still an issue, this should definitely be fixed.

@alistairjcbrown
Copy link
Author

@ljharb It's still an issue in v0.31.2

> $ nvm --version
0.31.2
> $ ./test.sh
Downloading https://nodejs.org/dist/v6.2.2/node-v6.2.2-darwin-x64.tar.xz...
######################################################################## 100.0%
mkdir: : No such file or directory
Binary download failed, trying source.
######################################################################## 100.0%
Checksums empty
mkdir: : No such file or directory
Binary download failed, trying source.
Detected that you have 8 CPU thread(s)
Set the number of jobs to 8 - 1 = 7 jobs to speed up the build
Installing node v1.0 and greater from source is not currently supported

@ljharb
Copy link
Member

ljharb commented Jun 28, 2016

In this case, the mkdir is failing on the binary install, forcing it to fall back to the source install, which isn't supported - so it should be failing with or without the set -e.

The mkdir warning is the part I find troubling - especially since that didn't fail in v0.29.

@ljharb
Copy link
Member

ljharb commented Jun 30, 2016

This appears to be working for me locally - does your $NVM_DIR exist? What does nvm debug say?

@alistairjcbrown
Copy link
Author

Details below with updated script. Interestingly changing from #!/bin/sh to #!/bin/bash causes the script to work, so this may be a compatibility issue with bourne shell.

Script used:

#!/bin/sh
set -e

echo "NVM_DIR: '$NVM_DIR'"
test -e $NVM_DIR && echo 'NVM_DIR exists'
echo ""

set +e
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
set -e

set +e
nvm debug
echo ""
set -e

nvm install 6.2.2

Output:

> $ ./test.sh
NVM_DIR: '/Users/alistairbrown/.nvm'
NVM_DIR exists

nvm --version: v0.31.2
$SHELL: /bin/zsh
$HOME: /Users/alistairbrown
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v5.2.0
which node: $NVM_DIR/versions/node/v5.2.0/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v5.2.0/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v5.2.0
npm root -g: $NVM_DIR/versions/node/v5.2.0/lib/node_modules

Downloading https://nodejs.org/dist/v6.2.2/node-v6.2.2-darwin-x64.tar.xz...
######################################################################## 100.0%
mkdir: : No such file or directory
Binary download failed, trying source.
######################################################################## 100.0%
Checksums empty
mkdir: : No such file or directory
Binary download failed, trying source.
Detected that you have 8 CPU thread(s)
Set the number of jobs to 8 - 1 = 7 jobs to speed up the build
Installing node v1.0 and greater from source is not currently supported

ljharb added a commit that referenced this issue Jul 11, 2016
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

No branches or pull requests

2 participants