nvm
nvm copied to clipboard
reinstall-packages failed within nvm_cd
Operating system and version:
macOS Big Sur v11.5.2
nvm debug output:
nvm --version: v0.38.0
$TERM_PROGRAM: Apple_Terminal
$SHELL: /bin/zsh
$SHLVL: 1
whoami: [EDITED]
${HOME}: /Users/[EDITED]
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v14.17.6/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8 (x86_64-apple-darwin20.0)'
uname -a: 'Darwin 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64 x86_64'
checksum binary: 'shasum'
OS version: macOS 11.5.2 20G95
curl: /usr/bin/curl, curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
wget: /usr/local/bin/wget, GNU Wget 1.21.1 hecho en darwin20.4.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: rm: aliased to rm -i (rm -i)
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /usr/bin/git, git version 2.30.1 (Apple Git-130)
ls: grep:: No such file or directory
grep: grep: aliased to grep --color (grep --color), grep (BSD grep) 2.5.1-FreeBSD
awk: /usr/bin/awk, awk version 20200816
nvm current: v14.17.6
which node: ${NVM_DIR}/versions/node/v14.17.6/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v14.17.6/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v14.17.6
npm root -g: ${NVM_DIR}/versions/node/v14.17.6/lib/node_modules
nvm ls output:
v8.17.0
v10.23.0
v10.24.1
v12.20.0
v14.15.1
v14.17.1
v14.17.2
v14.17.5
-> v14.17.6
default -> 14 (-> v14.17.6)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v14.17.6) (default)
stable -> 14.17 (-> v14.17.6) (default)
lts/* -> lts/fermium (-> v14.17.6)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0
lts/dubnium -> v10.24.1
lts/erbium -> v12.22.6 (-> N/A)
lts/fermium -> v14.17.6
How did you install nvm?
Homebrew
What steps did you perform?
nvm install 14 --reinstall-packages-from=node
What happened?
Downloading and installing node v14.17.6...
Downloading https://nodejs.org/dist/v14.17.6/node-v14.17.6-darwin-x64.tar.xz...
############################################################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v14.17.6 (npm v6.14.15)
VERSION=''
Reinstalling global packages from v14.17.5...
No installed global packages found...
Linking global packages from v14.17.5...
nvm_cd:cd:1: no such file or directory: /Users/[EDITED]/[VALID_LOCAL_PACKAGE_DIR]\n/Users/[EDITED]/[VALID_LOCAL_PACKAGE_DIR]
What did you expect to happen?
reinstall-packages to work instead of failing as shown above.
As you can see, it failed to parse/split the list of global packages as it is a single string with a /n instead of valid two paths.
Is there anything in any of your profile files that modifies the PATH?
No
(note: nvm is unsupported when installed via homebrew, as the formula indicates; please brew uninstall it and install it properly with the install script from the readme)
What does npm ls -g --depth=0 print out?
Operating system and version:
macOS Big Sur v11.5.2
nvm debugoutput:
nvm lsoutput:How did you install
nvm?Homebrew
What steps did you perform?
nvm install 14 --reinstall-packages-from=nodeWhat happened?
Downloading and installing node v14.17.6... Downloading https://nodejs.org/dist/v14.17.6/node-v14.17.6-darwin-x64.tar.xz... ############################################################################################################################################################################## 100.0% Computing checksum with shasum -a 256 Checksums matched! Now using node v14.17.6 (npm v6.14.15) VERSION='' Reinstalling global packages from v14.17.5... No installed global packages found... Linking global packages from v14.17.5... nvm_cd:cd:1: no such file or directory: /Users/[EDITED]/[VALID_LOCAL_PACKAGE_DIR]\n/Users/[EDITED]/[VALID_LOCAL_PACKAGE_DIR]What did you expect to happen?
reinstall-packagesto work instead of failing as shown above.As you can see, it failed to parse/split the list of global packages as it is a single string with a
/ninstead of valid two paths.Is there anything in any of your profile files that modifies the
PATH?No
@Maciej93 what version of nvm are you using? If not the latest, please upgrade and try again.
@ljharb just tried again to go from v14.17.6 to v16 and had the same problem.
The problem happens with the packages that were npm link'ed from local repositories. The ones installed globally from NPM were properly migrated.
Logs below:
$ nvm install 16 --reinstall-packages-from=node
Downloading and installing node v16.13.0...
Downloading https://nodejs.org/dist/v16.13.0/node-v16.13.0-darwin-x64.tar.xz...
############################################################################################################################################################################## 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v16.13.0 (npm v8.1.0)
VERSION=''
Reinstalling global packages from v14.17.6...
[EDITED]
Linking global packages from v14.17.6...
nvm_cd:cd:1: no such file or directory: /Users/[EDITED]/[VALID_LOCAL_DIR_1]\n/Users/[EDITED]/[VALID_LOCAL_DIR_2]
$ npm ls -g --depth=0
/Users/[EDITED]/.nvm/versions/node/v16.13.0/lib
└── [email protected]
$ nvm use 14
Now using node v14.17.6 (npm v6.14.15)
$ npm ls -g --depth=0
/Users/[EDITED]/.nvm/versions/node/v14.17.6/lib
├── [PACKAGE_NAME_1]@1.0.0 -> /Users/[EDITED]/[VALID_LOCAL_DIR_1]
├── [PACKAGE_NAME_2]@1.0.0 -> /Users/[EDITED]/[VALID_LOCAL_DIR_2]
└── [email protected]
$ nvm --version
0.39.0
Hope this helps. If you need any more information, please let me know. Would be awesome if we can figure this out!
In node 14, what's the output of nvm_npm_global_modules? Please try to redact as little as you can; specific characters might be important since we're doing string parsing.
@ljharb this is the output:
$ npm ls -g --depth=0
/Users/user/.nvm/versions/node/v14.17.6/lib
├── [email protected] -> /Users/user/Documents/package-1
├── [email protected] -> /Users/user/Documents/package-2
├── [email protected] -> /Users/user/Documents/package-3
├── [email protected]
└── [email protected]
$ nvm_npm_global_modules
No .nvmrc file found
Please see `nvm --help` or https://github.com/nvm-sh/nvm#nvmrc for more information.
////
$ nvm_npm_global_modules 14
[email protected] //// /Users/user/Documents/package-1
/Users/user/Documents/package-2
/Users/user/Documents/package-3
It is edited but believe me, there are no special chars or anything weird.
What's the output of type -a cd?
It is:
$ type -a cd
cd is a shell builtin
cd is /usr/bin/cd
aha, this is zsh - what's the output of setopt? The stock setopt on my zsh is:
combiningchars
interactive
monitor
shinstdin
zle
Yeah! I'm using zsh as described in the output of nvm debug 😄
The output of setopt on mine looks much larger:
$ setopt
alwaystoend
autocd
autopushd
combiningchars
completeinword
extendedhistory
noflowcontrol
histexpiredupsfirst
histignoredups
histignorespace
histverify
interactive
interactivecomments
login
longlistjobs
monitor
promptsubst
pushdignoredups
pushdminus
sharehistory
shinstdin
zle
Do you think any of these may be affecting nvm? My zsh is also almost stock. I only have some plugins enabled:
plugins=(common-aliases docker docker-compose git zsh-autosuggestions)
Absolutely it might be - what would be great is if you can binary search and try to figure out which option it is (or which plugin, but that's never been an issue before for nvm users).
Once we've narrowed it down, nvm can work around it so you don't have to keep that option disabled.