-
Notifications
You must be signed in to change notification settings - Fork 74
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
should always activate given version regardless of nvm_current_version
#222
Comments
nvm use
should always activate given version regardless of nvm_current_versionnvm use
should always activate given version regardless of nvm_current_version
nvm_current_version is internal to nvm.fish and isn't meant for user modification. Can you describe the actual problem you had? I'm not sure what you're attempting. |
The script above is just for debugging the issue. I'm not using nvm_current_version directly. Only Let me try again.
My use case is rare as node should always be managed by nvm. But it's unavoidable for me. And I would say, |
What steps did you follow according to the nvm documentation, and what didn't work? |
I only use
You can do these steps to reproduce it. # assuming you has node v20.11.1 in your system
fish_add_path ~/.local/share/nvm/v20.11.1/bin
# inside test dir, we need node 16
echo 16 > .nvmrc
function my_script
nvm use
node -v # -> it's 16 as expected
fish -c '
nvm use
node -v # -> expected 16 but its 20
'
end
# run test script inside test dir
my_script |
Why do you need to run nvm use twice? |
The first is for my interactive use. The one inside the script is because I want to run it for multiple projects that use different node versions. |
But do you need to start a new shell in your function? nvm is designed for interactive use first. |
The first I spin a new shell in the function because there are some other stuff that will affect my interactive shell that I don't want to. |
Not sure why your setup is so restrictive, but it seems like you might be using the wrong tool for the job. Regardless, I'm not sure about the ideal nvm use behavior in a subshell. Wonder what nvm.sh does in this context. |
I never use nvm.sh before so I'm not sure. nvm.fish is managed node for me so I want to rely on it as much as I can. I have some questions.
|
Great questions. Perhaps exporting isn't necessary, but I am sure I had a good reason for it when I originally wrote the code. I'll need to take some time to revisit this. Can't say exactly when, but for now, consider removing nvm.fish/functions/_nvm_version_activate.fish Lines 1 to 4 in c69e5d1
|
Thanks you. For now I'll fork nvm.fish and unexporting it. Also thanks a ton for making fisher. It makes installing packages super convenient. |
Hello,
This is my setup.
I use
fish_user_paths
to my global utils dir, which happen to have node 20 inside.I'm activating node 16 for work with
nvm use 16
.nvm_current_version
is 16 and exported.I'm run a subshell for my script.
The culprit is the check here:
nvm.fish/functions/nvm.fish
Lines 150 to 153 in c69e5d1
I don't know the reason for this, but I would expected
nvm use
to always active the given version.What do you think?
The text was updated successfully, but these errors were encountered: