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

Programs installed in the active multishell are available when calling fnm exec #1097

Open
leamingrad opened this issue Feb 15, 2024 · 0 comments

Comments

@leamingrad
Copy link

Summary

When using the fnm exec command, the PATH variable is set to a value which includes both the version being used and the active multishell.

This is confusing, as we can end up using a command associated with a different node version to the one passed into fnm exec.

Proposed Solution

I think that the way to fix this would be to change the code here which builds the path for an exec command, so that it removes the active multishell from the path as well as adding the version we are using for the exec to the path.

If that is sensible, I am happy to put up a PR.

Example to Reproduce

# Start with no node versions installed (and yarn not available from the system)
 $ fnm list
* system
 $ which yarn
yarn not found

# Install two versions of node
 $ fnm install 14.21.1
 $ fnm install 18.16.1
 $ fnm list
* v14.21.1 default
* v18.16.1
* system

# Install yarn on version 14
 $ fnm use 14.21.1
Using Node v14.21.1
 $ npm install -g yarn
...
added 1 package in 0.478s
 $ which yarn
/Users/me/Library/Caches/fnm_multishells/7130_1707823268447/bin/yarn

# If we switch to version 18, we cannot find yarn, but can find the version 14 one with exec
 $ fnm use 18.16.1
Using Node v18.16.1
 $ which yarn
yarn not found
 $ fnm exec --using 14.21.1 which yarn
/Users/james.owen/Library/Application Support/fnm/node-versions/v14.21.1/installation/bin/yarn
 $ fnm exec --using 18.16.1 which yarn

# If we switch to version 14, we can find yarn when we exec against either version, falling back to the one from the shell
 $ fnm use 14.21.1                    
Using Node v14.21.1
 $ fnm exec --using 14.21.1 which yarn
/Users/james.owen/Library/Application Support/fnm/node-versions/v14.21.1/installation/bin/yarn
 $ fnm exec --using 18.16.1 which yarn
/Users/james.owen/Library/Caches/fnm_multishells/7130_1707823268447/bin/yarn
 $ which yarn
/Users/james.owen/Library/Caches/fnm_multishells/7130_1707823268447/bin/yarn
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

1 participant