nvm: Unable to load nvm using oh-my-zsh

  • 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
  • How did you install nvm? (e.g. install script in readme, Homebrew): install script in readme, added the below to .zshrc
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
  • What steps did you perform? I opened my terminal, and it was non-responsive. If I open a new terminal and do the below, nvm will load
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
  • What happened? Trying to source nvm.sh from my .zshrc meant every new terminal would be unresponsive. After removing this from .zshrc I was able to open a terminal and try 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 23 (11 by maintainers)

Most upvoted comments

https://github.com/lukechilds/zsh-nvm#as-an-oh-my-zsh-custom-plugin

  1. git clone https://github.com/lukechilds/zsh-nvm ~/.oh-my-zsh/custom/plugins/zsh-nvm
  2. Then load as a plugin in your .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.

I’m seeing similar symptoms, WSL on 17741, zsh + omz, defunct sed, grep, and tr processes.

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.