Operating system and version: Arch Linux 4.10.9-1-ARCH / nvm 0.33.1
nvm debug output:
nvm --version: v0.33.1
$SHELL: /bin/bash
$HOME: /home/username
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist'
$NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist'
nvm current: system
which node: /usr/bin/node
which iojs: which: no iojs in (/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl)
which npm: /usr/bin/npm
npm config get prefix: /usr
npm root -g: /usr/lib/node_modules
nvm ls output:
How did you install nvm? (e.g. install script in readme, homebrew):
install script from cloned repo
What steps did you perform?
installed nvm, ran nvm.sh manually to set up the environment, through a script
What happened?
nvm.sh throws an unbound variable error on line 2474: $REINSTALL_PACKAGES_FROM - confirmed this isn't because of settings in the parent script
nvm.sh to complete successfully.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?/etc/profile sets PATH="/usr/local/sbin:/usr/local/bin:/usr/bin"I've managed to work around this by changing nvm.sh before execution:
sed -i '2474,2476s/$REINSTALL_PACKAGES_FROM/${REINSTALL_PACKAGES_FROM:-}/' /home/username/.nvm/nvm.sh
this seems similar to #1413 , which I also worked around by setting MANPATH="" and then unsetting it after nvm.sh but that issue is resolved in the master branch.
I have run into this too. The problem appears to be when running in a shell with set -u specified. There are a few similar bugs, another one I ran into is nvm.sh: line 3103: ALIAS: unbound variable.
These issues prevent using nvm from scripts with set -u specified, which sucks :(
@alexjurkiewicz @MechaLynx do you still see REINSTALL_PACKAGES_FROM appearing with the latest nvm?
@alexjurkiewicz if you'd mind filing a new issue for ALIAS, that'd be appreciated.
Unfortunately I'm seeing the error on a shared CI server, so I can't go and change the nvm version. For the record I saw the ALIAS error with 0.33.2. I'll file a new issue.
I still see REINSTALL_PACKAGES_FROM appearing with nvm 0.33.2 when used in conjunction with set -u.
@ljharb I tested nvm.sh using set -u in bash and also made a test script that ran nvm.sh using set -eu as well, in neither case does it complain about any unset variable.
I did a git reset --hard and pull on the repo before testing, so I'm using commit 4f626eac, the one with the fix.
I originally encountered this through a bigger script, which I can't test right now because I'm in the process of heavily refactoring it. I will try installing nvm on a fresh VM though (since the system I tried already had it installed), to make sure it's fixed.
FWIW, I was able to trigger this (while set-u was enabled) by doing an nvm install 7.8.0 immediately followed by an nvm use 7.8.0, with Node 7.5.0 already having been installed previously.
@joshdick Yeah I can reproduce that. The original unbound variable from nvm.sh is gone (tried it again on a fresh Manjaro install, without node installed - original report was with Arch) but requesting a valid version from nvm install results in the unbound error you reported. With invalid versions nvm exits before it gets to that point.
@joshdick @ljharb Running nvm use just quits for me, it doesn't cause the unbound variable error, it just gives up since there is no node installed. Even after installing nodejs from pacman, nvm use doesn't give me any errors and nvm use system works ok (I'm assuming that's not a meaningful test though). However, nvm ls says STABLE and UNSTABLE are unbound variables, but otherwise produces the rest of its output as normal.
All of this is with just set -u in bash running interactively, with the exception of the repeated tests from before.
Oh and sorry for not responding for 3 days now, I must have missed the mail among the rest.
Thanks, I'll see what I can do.
@MechaLynx i'm not sure what pacman is, and afaik only apt calls it "nodejs".
I can't reproduce any set -u errors with STABLE or UNSTABLE on latest master from nvm ls, and #1516 seems to have fixed REINSTALL_PACKAGES_FROM.
I'm going to close this for now, but please do file a new issue if you see any new instances of this problem. (Please wait until the next release before re-reporting REINSTALL_PACKAGES_FROM)
@ljharb Sure thing dude, I'll be putting it to the test with the original script soon anyway.
For future reference, pacman is the package manager for Arch Linux, and they _do_ call it nodejs :P. The reason I tested with Manjaro is because it's based on Arch and shares the same packages and basic setup. Their user repository of packages (those made by users) has nvm but I _didn't_ use that version in either case - both times it was the repo, just so nobody wonders if they read this issue in the future.