nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fish shell: error on load_nvm function

sairoko12 opened this issue · comments

Operating system and version:

macOS Ventura 13.1

nvm debug output:

nvm --version: v0.39.1
$TERM_PROGRAM: iTerm.app
$SHELL: /opt/homebrew/bin/fish
$SHLVL: 2
whoami: 'sairoko'
${HOME}: /Users/sairoko
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /Applications/Sublime Text.app/Contents/SharedSupport/bin:${HOME}/.local/bin:/opt/homebrew/bin:/usr/local/opt/python@3.7/bin:/usr/local/sbin:${HOME}/.pyenv/bin:${HOME}/.poetry/bin:${NVM_DIR}/versions/node/v14.19.0/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'fish, version 3.6.0'
uname -a: 'Darwin 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64'
checksum binary: 'shasum'
OS version: macOS 13.1 22C65
curl: /usr/bin/curl, curl 7.85.0 (x86_64-apple-darwin22.0) libcurl/7.85.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.47.0
wget: /opt/homebrew/bin/wget, GNU Wget 1.21.3 hecho en darwin22.1.0.
sed: /usr/bin/sed
cut: /usr/bin/cut
basename: /usr/bin/basename
rm: /bin/rm
mkdir: /bin/mkdir
xargs: /usr/bin/xargs
git: /opt/homebrew/bin/git, git version 2.39.0
grep: /usr/bin/grep, grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
awk: /usr/bin/awk, awk version 20200816
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:

       v14.19.0
       v18.13.0
->       system
default -> 14.19.0 (-> v14.19.0)
system -> 14.19.0 (-> v14.19.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.13.0) (default)
stable -> 18.13 (-> v18.13.0) (default)
lts/* -> lts/hydrogen (-> v18.13.0)
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.12 (-> N/A)
lts/fermium -> v14.21.2 (-> N/A)
lts/gallium -> v16.19.0 (-> N/A)
lts/hydrogen -> v18.13.0

How did you install nvm?

Yes, I have already installed nvm through the shell command from the readme file

What steps did you perform?

Use the function load_nvm for the fish shell

What happened?

When I navigate between my folders through shell the function load_nvm for the fish shell is invoked, so this function doesn't work correctly when using the following command nvm version because the alias is returned instead of the real version (for example v14.19.0) this provokes that each update in $PWD the nvm use default it's called

What did you expect to happen?

The load_nvm function evaluates correctly the current version

The proposed solution that works for me

# On ~/.config/fish/functions/load_nvm.fish
set -l node_version (nvm version (nvm current))

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

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

I don't use fish, so I'm not sure what to do here - this was added in #2208 by @jaredramirez. Maybe they can shed some light?

On ~/.config/fish/functions/load_nvm.fish

set -l node_version (nvm version (nvm current))