Skip to content

nvm use should always activate given version regardless of nvm_current_version #222

@dangh

Description

@dangh

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.

    fish -c "
        set -S nvm_current_version # -> 16 as it was imported from parent process
    
        nvm use 16 # has no effect as nvm_current_version is already 16
    
        node -v # -> 20 because of fish_user_paths
    "

The culprit is the check here:

nvm.fish/functions/nvm.fish

Lines 150 to 153 in c69e5d1

if test $ver != "$nvm_current_version"
set --query nvm_current_version && _nvm_version_deactivate $nvm_current_version
test $ver != system && _nvm_version_activate $ver
end

I don't know the reason for this, but I would expected nvm use to always active the given version.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions