Thanks to visit codestin.com
Credit goes to github.com

Skip to content

nvm use fails when NVM_DIR ends with a slash #1708

@chrisse27

Description

@chrisse27
  • Operating system and version: Linux

  • nvm debug output:

nvm --version: v0.33.8
$SHELL: /bin/bash
$HOME: /home/bamboo
$NVM_DIR: '$HOME/.nvm/'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist'
$NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist'
shell version: 'GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)'
uname -a: 'Linux 4.4.0-109-generic #132-Ubuntu SMP Tue Jan 9 19:52:39 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 16.04.3 LTS
curl: /usr/bin/curl, curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
wget: /usr/bin/wget, GNU Wget 1.17.1 built on linux-gnu.
git: /usr/bin/git, git version 2.7.4
grep: /bin/grep, grep (GNU grep) 2.25
awk: /usr/bin/awk, GNU Awk 4.1.3, API: 1.1 (GNU MPFR 3.1.4, GNU MP 6.1.0)
sed: /bin/sed, sed (GNU sed) 4.2.2
cut: /usr/bin/cut, cut (GNU coreutils) 8.25
basename: /usr/bin/basename, basename (GNU coreutils) 8.25
rm: /bin/rm, rm (GNU coreutils) 8.25
mkdir: /bin/mkdir, mkdir (GNU coreutils) 8.25
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0-git
nvm current: v6.9.1
which node: $NVM_DIR/versions/node/v6.9.1/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v6.9.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v6.9.1
npm root -g: $NVM_DIR/versions/node/v6.9.1/lib/node_modules
  • nvm ls output:
  • How did you install nvm? (e.g. install script in readme, homebrew):

Install script in readme

  • What steps did you perform?
nvm use 9
  • What happened?
nvm is not compatible with the npm config "prefix" option: currently set to "/home/bamboo/.nvm/versions/node/v8.9.1"
Run `nvm use --delete-prefix v8.9.1` to unset it.
  • What did you expect to happen?

That nvm switches to the new Node version.

This is a bug in the function nvm_tree_contains_path which cannot deal with trailing slashes in the NVM_DIR variable. removing the slash solves the problem. I anyway opened this issue to spare future users hours of painful debugging.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
  • If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions