8000 Default packages not installed correctly, nvm adds unnecessary arguements to npm install -g · Issue #2281 · nvm-sh/nvm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Default packages not installed correctly, nvm adds unnecessary arguements to npm install -g #2281

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

Closed
cbcoutinho opened this issue Aug 11, 2020 · 6 comments
Labels
bugs Oh no, something's broken :-( shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh

Comments

@cbcoutinho
Copy link

Operating system and version:

openSUSE Tumbleweed
nvm installed via homebrew (for linux)
NVM_DIR=~/.nvm

$ cat $NVM_DIR/default-packages
fast-cli
npm-check-updates

nvm debug output:

$ nvm debug
nvm --version: v0.35.3
$SHELL: /usr/bin/zsh
$SHLVL: 2
${HOME}: /home/chris
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: ${NVM_DIR}/versions/node/v13.0.1/bin:${HOME}/.jenv/shims:${HOME}/.jenv/bin:${HOME}/.local/bin:${HOME}/.pyenv/shims:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${HOME}/.jenv/shims:${HOME}/.jenv/bin:${HOME}/.local/bin:${HOME}/.pyenv/shims:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:${HOME}/.poetry/bin:${HOME}/.cargo/bin:${HOME}/.go/bin:/sbin:/usr/sbin:/usr/local/sbin:${HOME}/bin:${HOME}/.local/bin:${HOME}/bin:/usr/local/bin:/usr/bin:/bin:${HOME}/.fzf/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.8 (x86_64-suse-linux-gnu)'
uname -a: 'Linux 5.7.11-1-default #1 SMP Wed Jul 29 09:32:21 UTC 2020 (5015994) x86_64 x86_64 x86_64 GNU/Linux'
OS version: Welcome to openSUSE Tumbleweed 20200810 - Kernel  ().
curl: /usr/bin/curl, curl 7.71.1 (x86_64-suse-linux-gnu) libcurl/7.71.1 OpenSSL/1.1.1g-fips zlib/1.2.11 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh/0.9.3/openssl/zlib nghttp2/1.41.0
wget: /usr/bin/wget, GNU Wget 1.20.3 built on linux-gnu.
git: /usr/bin/git, git version 2.28.0
ls: cannot access 'grep:': No such file or directory
grep: grep: aliased to grep --color=auto (grep --color=auto), grep (GNU grep) 3.4
awk: /usr/bin/awk, GNU Awk 5.1.0, API: 3.0
sed: /usr/bin/sed, sed (GNU sed) 4.8
cut: /usr/bin/cut, cut (GNU coreutils) 8.32
basename: /usr/bin/basename, basename (GNU coreutils) 8.32
ls: cannot access 'rm:': No such file or directory
rm: rm: aliased to rm -iv (rm -iv), rm (GNU coreutils) 8.32
ls: cannot access 'mkdir:': No such file or directory
mkdir: mkdir: aliased to mkdir -p (mkdir -p), mkdir (GNU coreutils) 8.32
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.7.0
nvm current: v13.0.1
which node: ${NVM_DIR}/versions/node/v13.0.1/bin/node
which iojs: iojs not found
which npm: ${NVM_DIR}/versions/node/v13.0.1/bin/npm
npm config get prefix: ${NVM_DIR}/versions/node/v13.0.1
npm root -g: ${NVM_DIR}/versions/node/v13.0.1/lib/node_modules

nvm ls output:

$ nvm ls
�[0;34m    iojs-v3.3.1�[0m
�[0;34m       v12.18.2�[0m
�[0;34m       v12.18.3�[0m
�[0;32m->      v13.0.1�[0m
�[0;34m       v13.14.0�[0m
�[0;33m         system�[0m
�[0;34mdefault�[0m �[0;90m->�[0m �[1;33mlts/*�[0m (�[0;90m->�[0m �[0;34mv12.18.3�[0m)
�[0;34miojs�[0m �[0;90m->�[0m �[0;34miojs-v3.3�[0m (�[0;90m->�[0m �[0;34miojs-v3.3.1�[0m) �[0;37m(default)�[0m
�[0;34mnode�[0m �[0;90m->�[0m �[0;34mstable�[0m (�[0;90m->�[0m �[0;34mv13.14.0�[0m) �[0;37m(default)�[0m
�[0;34mstable�[0m �[0;90m->�[0m �[0;34m13.14�[0m (�[0;90m->�[0m �[0;34mv13.14.0�[0m) �[0;37m(default)�[0m
�[1;31munstable�[0m �[0;90m->�[0m �[1;31mN/A�[0m �[0;37m(default)�[0m
�[1;33mlts/*�[0m �[0;90m->�[0m �[1;33mlts/erbium�[0m (�[0;90m->�[0m �[0;34mv12.18.3�[0m)
�[1;33mlts/argon�[0m �[0;90m->�[0m �[1;31mv4.9.1�[0m (�[0;90m->�[0m �[1;31mN/A�[0m)
�[1;33mlts/boron�[0m �[0;90m->�[0m �[1;31mv6.17.1�[0m (�[0;90m->�[0m �[1;31mN/A�[0m)
�[1;33mlts/carbon�[0m �[0;90m->�[0m �[1;31mv8.17.0�[0m (�[0;90m->�[0m �[1;31mN/A�[0m)
�[1;33mlts/dubnium�[0m �[0;90m->�[0m �[1;31mv10.22.0�[0m (�[0;90m->�[0m �[1;31mN/A�[0m)
�[1;33mlts/erbium�[0m �[0;90m->�[0m �[0;34mv12.18.3�[0m

How did you install nvm?

Homebrew (for linux)

What steps did you perform?

 /h/chris  cd $(mktemp -d) # to make sure this was in a clean and empty directory
 /t/tmp.ybs2YOqNEf  ls
 /t/tmp.ybs2YOqNEf  pwd
/tmp/tmp.ybs2YOqNEf
 /t/tmp.ybs2YOqNEf  nvm install v13.0
Downloading and installing node v13.0.1...
Downloading https://nodejs.org/dist/v13.0.1/node-v13.0.1-linux-x64.tar.xz...
############################################################################################################################################################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v13.0.1 (npm v6.12.0)
Installing default global packages from /home/chris/.nvm/default-packages...
npm install -g --quiet fast-cli npm-check-updates
removed '/tmp/tmp.vQIbry9Fx6/default-packages'
removed directory '/tmp/tmp.vQIbry9Fx6'
npm ERR! code ENOLOCAL
npm ERR! Could not install from "../tmp.vQIbry9Fx6/default-packages" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/chris/.npm/_logs/2020-08-11T15_41_34_924Z-debug.log
Failed installing default packages. Please check if your default-packages file or a package in it has problems!

Output from npm debug log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/home/chris/.nvm/versions/node/v13.0.1/bin/node',
1 verbose cli   '/home/chris/.nvm/versions/node/v13.0.1/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   '--quiet',
1 verbose cli   'fast-cli',
1 verbose cli   'npm-check-updates',
1 verbose cli   'removed',
1 verbose cli   '/tmp/tmp.vQIbry9Fx6/default-packages',
1 verbose cli   'removed',
1 verbose cli   'directory',
1 verbose cli   '/tmp/tmp.vQIbry9Fx6'
1 verbose cli ]
2 info using npm@6.12.0
3 info using node@v13.0.1
4 verbose npm-session 770d11cda26dfead
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file:/tmp/tmp.vQIbry9Fx6/default-packages Could not install from "../tmp.vQIbry9Fx6/default-packages" as it does not contain a package.json file.
8 silly fetchPackageMetaData error for file:/tmp/tmp.vQIbry9Fx6 Could not install from "../tmp.vQIbry9Fx6" as it does not contain a package.json file.
9 http fetch GET 200 https://registry.npmjs.org/removed 54ms (from cache)
10 http fetch GET 200 https://registry.npmjs.org/directory 54ms (from cache)
11 silly pacote tag manifest for removed@latest fetched in 60ms
12 silly pacote tag manifest for directory@latest fetched in 59ms
13 http fetch GET 304 https://registry.npmjs.org/fast-cli 250ms (from cache)
14 silly pacote tag manifest for fast-cli@latest fetched in 266ms
15 http fetch GET 304 https://registry.npmjs.org/npm-check-updates 252ms (from cache)
16 silly pacote tag manifest for npm-check-updates@latest fetched in 260ms
17 timing stage:rollbackFailedOptional Completed in 1ms
18 timing stage:runTopLevelLifecycles Completed in 310ms
19 verbose stack Error: ENOENT: no such file or directory, open '/tmp/tmp.vQIbry9Fx6/default-packages/package.json'
20 verbose cwd /tmp/tmp.ybs2YOqNEf
21 verbose Linux 5.7.11-1-default
22 verbose argv "/home/chris/.nvm/versions/node/v13.0.1/bin/node" "/home/chris/.nvm/versions/node/v13.0.1/bin/npm" "install" "-g" "--quiet" "fast-cli" "npm-check-updates" "removed" "/tmp/tmp.vQIbry9Fx6/default-packages" "removed" "directory" "/tmp/tmp.vQIbry9Fx6"
23 verbose node v13.0.1
24 verbose npm  v6.12.0
25 error code ENOLOCAL
26 error Could not install from "../tmp.vQIbry9Fx6/default-packages" as it does not contain a package.json file.
27 verbose exit [ 1, true ]

What happened?

It looks like nvm tacks on some unnecessary arguments to the npm install -g command, causing problems...

What did you expect to happen?

Default packages are installed globally in new environment

Is there anything in any of your profile files that modifies the PATH?

Somewhere in my .zshrc is export NVM_DIR=~/.nvm

8000
@cbcoutinho cbcoutinho changed the title Default packages not installed correctly, nvm adds unnecessary arguements to npm install -g causing Default packages not installed correctly, nvm adds unnecessary arguements to npm install -g Aug 11, 2020
@ljharb
Copy link
Member
ljharb commented Aug 11, 2020

That removed '/tmp/tmp.vQIbry9Fx6/default-packages' output doesn't seem standard. Have you perhaps overridden the rm builtin? What does nvm_npm_global_modules output?

@ljharb
Copy link
Member
ljharb commented Aug 11, 2020

Ohhh also, can you verify the contents of $NVM_DIR/default-packages? What does nvm_get_default_packages output? Have you perhaps overridden xargs?

@cbcoutinho
Copy link
Author

I've alias the rm command, xargs is just /usr/bin/xargs:

$ which rm
rm: aliased to rm -iv
$ nvm_npm_global_modules
fast-cli@2.3.0 npm-check-updates@7.0.4 serverless@1.78.1 ////
$ nvm_get_default_packages
fast-cli npm-check-updates
removed '/tmp/tmp.yb6EU9yNFh/default-packages'
removed directory '/tmp/tmp.yb6EU9yNFh'
$ cat $NVM_DIR/default-packages
fast-cli
npm-check-updates

@ljharb
Copy link
Member
ljharb commented Aug 11, 2020

ah - nvm_get_default_packages is using trap "rm -rf '$WORK'" EXIT which is likely running into this. While overriding shell builtins is always a bad idea, nvm shouldn't be brittle to this.

However, I'm having trouble reproducing this. Where are you creating that alias? (like, in which profile file)

@cbcoutinho
Copy link
Author
cbcoutinho commented Aug 11, 2020

Hmm, that is unexpected - I've never run into an issue related to aliasing basic commands; however, unaliasing rm causes the default packages to install properly. More specifically, the verbose (-v) flag causes the error - if I keep the prompt (-i) flag it still works properly.

I use zsh, and my dotfiles are on github if you realy are having trouble reproducing. You can see my zsh config here: cbcoutinho/.dotfiles/config/zsh. The rm alias is defined in aliases.zsh

@ljharb
Copy link
Member
ljharb commented Aug 11, 2020

Ah, I was trying in bash. I assume -i doesn't activate in a non-TTY, so that's not a problem.

I'll try to repro it in zsh, and if so, see what I can do about it in nvm.

@ljharb ljharb closed this as completed in 16b75b7 Aug 11, 2020
@ljharb ljharb added bugs Oh no, something's broken :-( shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh labels Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugs Oh no, something's broken :-( shell alias clobbering Anything dealing with users shadowing builtins with aliases or functions. shell: zsh
Projects
None yet
Development

No branches or pull requests

2 participants
0