nvm: nvm current returns system instead of version number, suspect nvm use not working

problem description

nvm current returns system instead of version number (i.e. v16.13.1). I need the version number not an alias, I suspect nvm use vX.Y.Z is not working.

Operating system and version:

macOS 12.1 21C52 arm64

nvm debug output:

nvm --version: v0.39.0
$TERM_PROGRAM: tmux
$SHELL: /opt/homebrew/bin/bash
$SHLVL: 2
whoami: 'sergi'
${HOME}: /Users/sergi
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:${NVM_DIR}/versions/node/v16.13.0/bin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/findutils/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/kitty.app/Contents/MacOS:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin:${HOME}/bin:${HOME}/.config/bin:/usr/local/bin:/usr/local/sbin:usr/bin:/usr/sbin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 5.1.12(1)-release (aarch64-apple-darwin21.1.0)'
uname -a: 'Darwin 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000 arm64'
checksum binary: 'sha256sum'
OS version: macOS 12.1 21C52
curl: /usr/bin/curl, curl 7.77.0 (x86_64-apple-darwin21.0) libcurl/7.77.0 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.42.0
wget: /opt/homebrew/bin/wget, GNU Wget 1.21.2 built on darwin21.1.0.
sed: /opt/homebrew/opt/gnu-sed/libexec/gnubin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm (rm -i)
mkdir: /bin/mkdir
xargs: /opt/homebrew/opt/findutils/libexec/gnubin/xargs
git: /opt/homebrew/bin/git, git version 2.34.1
grep: /opt/homebrew/opt/grep/libexec/gnubin/grep, grep (GNU grep) 3.7
awk: /opt/homebrew/bin/awk, awk version 20180827
nvm current: system
which node: /opt/homebrew/bin/node
which iojs:
which npm: /opt/homebrew/bin/npm
npm config get prefix: /opt/homebrew
npm root -g: /opt/homebrew/lib/node_modules

nvm ls output:

       v12.14.1
       v16.13.0
->       system
default -> v16.13.0
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v16.13.0) (default)
stable -> 16.13 (-> v16.13.0) (default)
lts/* -> lts/gallium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.7 (-> N/A)
lts/fermium -> v14.18.2 (-> N/A)
lts/gallium -> v16.13.1 (-> N/A)

How did you install nvm?

Homebrew

What steps did you perform?

brew install nvm

What happened?

Worked

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

Yes, PATH is listed in the debug output above

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 29 (11 by maintainers)

Most upvoted comments

I can confirm this is now working in/outside of tmux. I did:

  1. uninstall nvm, node, yarn
  2. install nvm via git
  3. add to path
  4. install node via nvm
  5. install yarn via brew

thank you again

OHMY, what an embarrassment, I cannot read. Yes, uninstalling brew nvm and running the official install from curl did the trick. Please accept my apologies, and thank you.

ok, then i don’t understand why nvm isn’t able to force its stuff to go in the front of the PATH.

yeah, same here 😃

Do you have a default set? nvm alias default node?

Yes, 16. But it doesn’t matter, brew version (17) wins.

To be clear, it is working now, but it’s a bit annoying to trace and discover. Just posted here so it can be tracked, for other people. Thank you again.

rearranging does not work, tried everything there. but I just fixed it adding this in my bash profile:

# Dynamically add all node versions installed via nvm to beginning of PATH,
# to take precedence over any other node version 
# (i.e. installed via brew install node or any formula dependencies)
for f in $HOME/.nvm/versions/node/*; do
  if [ -d "$f" ]; then
      PATH=$f/bin:$PATH
  fi
done

I’ll close this for now, but will immediately reopen it if there’s something actionable for nvm. Happy to continue discussing regardless.

Yes, it’s currently a mess. Most likely still artifacts from previous brew installs, since I was convinced brew was a viable option. I will try to remove all traces of nvm, npm, node, … and reinstall nvm from curl/git again, to see if that helps. Thank you again.

In that case it’s likely a PATH issue. Make sure sourcing nvm is the last thing in your profile file; or at least, that it happens after the last thing that prepends to the path.

It’s possibly 16.0.0 doesn’t support it; but 16 latest certainly does. There’s a whole section in nvm’s readme about it.

Yeah, but same happens for v16.13.1, I still get the system response as if nvm is not used at all, which is driving me nuts.