Operating system and version: Ubuntu 16.04 (WSL on Windows 10)
nvm debug output:
nvm --version: v0.33.11
$SHELL: zsh
$SHLVL: 4
$HOME: /home/skuzzer
$NVM_DIR: '$HOME/.nvm'
$PATH: $NVM_DIR/versions/node/v10.5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'zsh 5.1.1 (x86_64-ubuntu-linux-gnu)'
uname -a: 'Linux 4.4.0-17713-Microsoft #1000-Microsoft Fri Jul 06 15:51:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux'
OS version: Ubuntu 16.04.4 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: grep: aliased to grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} (grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}), 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: v10.5.0
which node: $NVM_DIR/versions/node/v10.5.0/bin/node
which iojs: iojs not found
which npm: $NVM_DIR/versions/node/v10.5.0/bin/npm
nvm ls output:N/A. Command fails to run, locks up terminal it is run in
nvm? (e.g. install script in readme, Homebrew): install script in readme, added the below to .zshrcexport NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
export NVM_DIR="$HOME/.nvm"
. "$NVM_DIR/nvm.sh"
However if I open a new terminal and do the below, nvm fails to load and the terminal becomes unresponsive
export NVM_DIR="$HOME/.nvm"
source $NVM_DIR/nvm.sh
zsh -x $NVM_DIR/nvm.sh to see where the script was locking up. The bottom of that output looks like the below+nvm:656> MANPATH=/home/skuzzer/.nvm/versions/node/v10.5.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man
+nvm:657> export MANPATH
+nvm:659> export PATH
+nvm:660> hash -r
+nvm:661> export NVM_BIN=/home/skuzzer/.nvm/versions/node/v10.5.0/bin
+nvm:662> [ '' '=' true ']'
+nvm:665> local NVM_USE_OUTPUT
+nvm:666> NVM_USE_OUTPUT=''
+nvm:667> [ 1 -ne 1 ']'
+nvm:674> [ _v10.5.0 '!=' _system ']'
+nvm:675> local NVM_USE_CMD
+nvm:676> NVM_USE_CMD='nvm use --delete-prefix'
+nvm:677> [ -n v10.5.0 ']'
+nvm:678> NVM_USE_CMD='nvm use --delete-prefix v10.5.0'
+nvm:680> [ 1 -eq 1 ']'
+nvm:681> NVM_USE_CMD='nvm use --delete-prefix v10.5.0 --silent'
+nvm:683> nvm_die_on_prefix 0 'nvm use --delete-prefix v10.5.0 --silent'
+nvm_die_on_prefix:1> local NVM_DELETE_PREFIX
+nvm_die_on_prefix:2> NVM_DELETE_PREFIX=0
+nvm_die_on_prefix:3> case 0 (0)
+nvm_die_on_prefix:10> local NVM_COMMAND
+nvm_die_on_prefix:11> NVM_COMMAND='nvm use --delete-prefix v10.5.0 --silent'
+nvm_die_on_prefix:12> [ -z 'nvm use --delete-prefix v10.5.0 --silent' ']'
+nvm_die_on_prefix:19> [ -n '' ']'
+nvm_die_on_prefix:32> local NVM_NPM_CONFIG_PREFIX_ENV
+nvm_die_on_prefix:33> NVM_NPM_CONFIG_PREFIX_ENV=+nvm_die_on_prefix:33> env
+nvm_die_on_prefix:33> NVM_NPM_CONFIG_PREFIX_ENV=+nvm_die_on_prefix:33> nvm_grep -i NPM_CONFIG_PREFIX
+nvm_grep:1> GREP_OPTIONS='' grep -i NPM_CONFIG_PREFIX
+nvm_die_on_prefix:33> NVM_NPM_CONFIG_PREFIX_ENV=+nvm_die_on_prefix:33> tail -1
+nvm_die_on_prefix:33> NVM_NPM_CONFIG_PREFIX_ENV=+nvm_die_on_prefix:33> awk -F '=' '{print $1}'
+nvm_die_on_prefix:33> NVM_NPM_CONFIG_PREFIX_ENV=''
+nvm_die_on_prefix:34> [ -n '' ']'
+nvm_die_on_prefix:45> nvm_has npm
+nvm_has:1> type npm
+nvm_die_on_prefix:49> local NVM_NPM_PREFIX
+nvm_die_on_prefix:50> NVM_NPM_PREFIX=+nvm_die_on_prefix:50> npm config '--loglevel=warn' get prefix
What did you expect to happen?
Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH? Yes, running WSL modifies the path
Can you share your zshrc? Specifically, what aliases do you have set up, and what zsh options have you enabled?
It's pretty minimal
PATH="$PATH:/usr/local/go/bin:$HOME/go/bin"
export ZSH=/home/skuzzer/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
alias ssh-screen="ssh-agent screen"
#export NVM_DIR="$HOME/.nvm"
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
what's in oh-my-zsh.sh? is it the stock omz?
Yep, stock
Do you have a system node and/or npm?
If so, with nvm commented out, can you run npm config get prefix?
Unfortunately I don't, I removed them to move to nvm
Hmm - can you try adding --no-use to the line that sources nvm, and see if that allows your shell to load?
If so, then can you try nvm use --delete-prefix node?
Adding --no-use allowed the shell to load, nvm use --delete-prefix node isn't working, just hangs
@skuzzer thanks - if you set -x; nvm use node, what do you get?
That stops at +nvm_die_on_prefix:50> NVM_NPM_PREFIX=+nvm_die_on_prefix:50> npm config '--loglevel=warn' get prefix
so that means that the nvm-installed node's npm is what's hanging.
To get you in a state where you can reproduce it without nvm, you'd have to edit your nvm.sh file and add a return 0 inside the first line of nvm_die_on_prefix - then, you should end up with a node/npm available, and you should be able to reproduce that npm config get prefix (with or without the --loglevel=warn) is hanging. If so, then it'd be an issue with npm itself.
@ljharb sorry for the delayed reply
I've added the return 0 into nvm_die_on_prefix, this does result in node/npm being available, it also results in npm config get prefix returning successfully (both with and without --loglevel=warn)
➜ ~ npm config get prefix
/home/skuzzer/.nvm/versions/node/v10.5.0
Wow, that’s very confusing then. You could try running each line inside nvm_die_on_prefix, one at a time, and see if any of this hangs - maybe the loop over env vars?
Quite confusing. That seems to run fine. I'll try to repeat later in case I missed something.
If I load a shell where I've had the return 0 inside the nvm_die_on_prefix function I can then remove the return 0 and do zsh -x ~/.nvm/nvm.sh without an error
When this does hang I'm being left with a defunct tr process
ooh, what does which tr say?
/usr/bin/tr
Unsure if this is helpful/representative of what normally happens, but I tried to run this with strace and had the following process tree when it locked up
skuzzer 2464 0.0 0.0 16700 520 pts/2 S 10:17 0:00 zsh .nvm/nvm.sh
skuzzer 2476 0.0 0.0 16700 488 pts/2 S 10:18 0:00 \_ zsh .nvm/nvm.sh
skuzzer 2489 0.0 0.0 16700 304 pts/2 S 10:18 0:00 \_ zsh .nvm/nvm.sh
skuzzer 2490 0.0 0.0 16700 512 pts/2 S 10:18 0:00 \_ zsh .nvm/nvm.sh
skuzzer 2510 0.0 0.0 16716 448 pts/2 S 10:18 0:00 | \_ zsh .nvm/nvm.sh
skuzzer 2511 15.7 0.0 16716 328 pts/2 t 10:18 3:13 | \_ zsh .nvm/nvm.sh
skuzzer 2513 0.0 0.0 0 0 pts/2 Z 10:18 0:00 | \_ [tr] <defunct>
skuzzer 2491 0.0 0.0 16700 420 pts/2 S 10:18 0:00 \_ zsh .nvm/nvm.sh
skuzzer 2494 0.0 0.0 14176 208 pts/2 S 10:18 0:00 | \_ grep -e ^v
skuzzer 2493 0.0 0.0 13328 120 pts/2 S 10:18 0:00 \_ cut -c2-
skuzzer 2495 0.0 0.0 13328 120 pts/2 S 10:18 0:00 \_ cut -d . -f 1,2
skuzzer 2497 0.0 0.0 13332 120 pts/2 S 10:18 0:00 \_ uniq
I wonder if this could possibly be a zsh/WSL bug? Non-windows zsh users don't seem to run into it, and I've only encountered people using bash with WSL so far.
I'm seeing similar symptoms, WSL on 17741, zsh + omz, defunct sed, grep, and tr processes.
https://github.com/lukechilds/zsh-nvm#as-an-oh-my-zsh-custom-plugin
.zshrc: plugins+=(zsh-nvm)Just tried it out. Did steps 1 and 2 above, closed wsl, then when I repoened it it automaticalli installed NVM, and it's working.
Not sure if my issue is related, but maybe this will help. I started getting tr usage statements on pretty much any shell operation. The culprit was a global alias on t that was conflicting with this line in nvm.sh: https://github.com/nvm-sh/nvm/blob/master/nvm.sh#L2302
Making the alias non-global solved the issue.
@mcw0933 it’d be great if you filed that as a separate issue; also if you tried quoting the t’s there and seeing if it avoids the alias?
It's working for me now. Maybe this issue should be closed.
Closing, but will be happy to reopen if needed.
Most helpful comment
https://github.com/lukechilds/zsh-nvm#as-an-oh-my-zsh-custom-plugin
.zshrc:plugins+=(zsh-nvm)Just tried it out. Did steps 1 and 2 above, closed wsl, then when I repoened it it automaticalli installed NVM, and it's working.