Skip to content
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

nvm use sets wrong version #237

Open
scarf005 opened this issue Jan 10, 2025 · 1 comment
Open

nvm use sets wrong version #237

scarf005 opened this issue Jan 10, 2025 · 1 comment

Comments

@scarf005
Copy link

scarf005 commented Jan 10, 2025

Problem

Sometimes nvm use {version} will point to wrong version.

> nvm use 18
Now using Node v23.5.0 (npm 10.9.2) /opt/homebrew/Cellar/node/23.5.0/bin/node

in this case, despite running nvm use 18, nvm wrongly points to node 23.

> nvm use 18
Now using Node v23.5.0 (npm 10.9.2) /opt/homebrew/Cellar/node/23.5.0/bin/node
> nvm use 23
Now using Node v23.3.0 (npm 10.9.0) ~/.local/share/nvm/v23.3.0/bin/node
> nvm use 18
Now using Node v18.12.1 (npm 8.19.2) ~/.local/share/nvm/v18.12.1/bin/nod

this can be workaround by switching to a different version then setting desired version.

System information

on m1 macos

$ nvm --version
nvm, version 2.2.16
$ fish --version
fish, version 3.7.1
$ cat .nvmrc
18.12.1
@Morpheus0x
Copy link

I am experiencing the same issue. When I open a new fish terminal in VSCodium (WSL 2.0, Debian 12), nvm seems to assume the last node version set by nvm use is active. However, it actually uses the system node version. I also have to do this workaround described above every time I launch a shell in vscode. I do not have the .nvmrc file @scarf005 prints out, however the env var nvm_current_version seems to be responsible for this mismatch. On opening a new shell it says v22.13.0 but node --version prints v18.0.0.

The issue appears to be due to how a new shell is opened. VSCode seems to initialize the shell differently than the normal Windows terminal does. I don't know if this is something that can be fixed here, or is just how fish behaves when a new "non-login" shell is initialized. I tried fixing this by setting the vscode setting "terminal.external.linuxExec": "wsl --shell-type login" (previously "terminal.external.linuxExec": "wsl"), however this doesn't seem to fix the issue.

This issue seems to be related to #222 since running fish -c "node --version" also prints v18.0.0, even though the fish shell outside uses the correct node v22.13.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants