jorgebucaran / nvm.fish

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

node is inaccessible until I run nvm use ... #216

Closed marcinjahn closed 9 months ago

marcinjahn commented 9 months ago

Anytime I want to use node, npm, etc., I have to invoke nvm use 18 first. How do I make it so that node is available without invoking nvm use first?

I tried adding set --universal nvm_default_version v18 to my fish.config, but that didn't change anything.

jorgebucaran commented 9 months ago

The documentation covers this functionality. It seems your problem might lie elsewhere. It's possible that another tool or dependency is modifying the PATH after nvm. Alternatively, there could be an unusual configuration on your end. For instance, universal variables are intended for interactive use, and it seems they are being used incorrectly in your case.

Additionally, you might be using an outdated version of Fish.

I'm going to close this issue here, as it does not appear to be a bug in nvm. However, if you provide more details about your configuration, I may be able to help.

marcinjahn commented 9 months ago

Hi @jorgebucaran, interestingly, right now, after a reinstall of your awesome plugin, it all seems to work. However, I admit, I'm new to fish, so I'm not entirely sure what I'm doing sometimes. My config.fish looks as follows:

set -gx EDITOR vim
set -gx VISUAL vim
set -gx PAGER less

set -gx DOCKER_HOST unix:///run/user/1000/podman/podman.sock
set -gx NVM_LAZY_LOAD true
set -gx NVM_COMPLETION true
set -gx DOTNET_CLI_TELEMETRY_OPTOUT 1
set -gx FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT 1

set -U fish_greeting
set --universal nvm_default_version v18

fish_add_path ~/bin
fish_add_path ~/sbin
fish_add_path ~/scripts
fish_add_path ~/opt/homebrew/bin
fish_add_path ~/opt/homebrew/sbin
fish_add_path ~/opt/local/bin
fish_add_path ~/opt/local/sbin
fish_add_path ~/.bun/bin
fish_add_path ~/.local/share/JetBrains/Toolbox/scripts
fish_add_path ~/.dotnet/tools

if status is-interactive
    jump shell fish | source
end

Does it look alright?

Oh, and I'm using fish 3.6.1

jorgebucaran commented 9 months ago

Avoid setting universal variables in your config.fish. Refer to the Fish documentation to better understand the purpose and usage of universal variables. Similarly, since fish_add_path sets universal variables, it's best used interactively, not in your config.fish. Optionally, consider setting EDITOR, VISUAL, PAGER as universal variables too, to streamline your config. Additionally, if you like jump, you might find fzf.fish interesting.

Fish it's a shell emphasizing interactivity over configuration. This isn't a rule, but a general principle.

marcinjahn commented 9 months ago

Thanks, I'll have to educate myself on this a bit more :)