jorgebucaran / nvm.fish

The Node.js version manager you'll adore, crafted just for Fish
https://git.io/nvm.fish
MIT License
2.08k stars 69 forks source link

NVM defaulting to system #128

Closed jrschumacher closed 3 years ago

jrschumacher commented 3 years ago

fish: 3.1.2 fisher: 4.1.0 jorgebucaran/nvm.fish: 2.0.1


nvm is defaulting to system depsite $nvm_default_version being set to v14.14.3. Additionally, if I try to use nvm use lts it will use the syustem default and if I try to install it (without removal) it will continue using it.

I have to uninstall the version of node I want to use to actually use that version of node. (And I have to do this every time I open a new shell)

image

jrschumacher commented 3 years ago

129 solved the problem for me, but not confident that the read command is used correctly.

jorgebucaran commented 3 years ago

I have to uninstall the version of node I want to use to actually use that version of node.

I wasn't able to reproduce your results.

スクリーンショット 2020-12-29 13 05 53

And I have to do this every time I open a new shell.

Correct. The nvm install command activates the specified Node version only in the current environment.

jorgebucaran commented 3 years ago

TL;DR: Can I get a printf "%s\n" $PATH before and after you run nvm use?

I believe you had already used nvm install lts and successfully installed v14.15.3 at some point. I know this because the npm version shown in your screenshot (6.14.9) is from the npm that ships with Node v14.15.3. This means both of your nvm use lts and nvm install lts activated v14.15.3 as you expected. The problem was that we displayed your system node version instead, which comes from _nvm_node_info.

To get the Node version, _nvm_node_info runs command node and console.logs process.version. Maybe /usr/local/bin is before ~/.local/share/nvm/v14.15.3/bin in your $PATH.

That would be the case if you're somehow manually adding node to your $PATH, e.g., in your config.fish.

jorgebucaran commented 3 years ago

I've pushed a few tweaks, so just to be sure, please uninstall this plugin (to clear all nvm variables from the environment) and install it again.

fisher remove jorgebucaran/nvm.fish && fisher install jorgebucaran/nvm.fish

Now try to use nvm and let me know if this helped at all with your issue.

jrschumacher commented 3 years ago

@jorgebucaran I found the issue. In my config.fish I was setting set -gx PATH /usr/local/bin ~/.bin $PATH which was overriding the path that nvm adds.

On that, I was looking over the code, expecting some on-event for when nvm sets the new path, but I fear it might be mny lack of knowledge in how fish manages environment variables with set. It appears that I do not need to add these to the config.fish, but just set it universally and fish will do the rest.