-
Notifications
You must be signed in to change notification settings - Fork 71
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 current
reverts the used node version
#13
Comments
I was not able to reproduce the bug: ~ $ cat .config/fish/functions/nvm.fish
function nvm
bass source ~/.nvm/nvm.sh ';' nvm $argv
end
~ $ nvm use v4
Now using node v4.1.1 (npm v2.14.4)
~ $ which node
/Users/edc/.nvm/versions/node/v4.1.1/bin/node
~ $ cd tmp
~/tmp $ cat .nvmrc
v0.10.40
~/tmp $ nvm use
Found /Users/edc/tmp/.nvmrc with version <v0.10.40>
Now using node v0.10.40 (npm v1.4.28)
~/tmp $ which node
/Users/edc/.nvm/v0.10.40/bin/node
~/tmp $ nvm current
v0.10.40
~/tmp $ which node
/Users/edc/.nvm/v0.10.40/bin/node
~/tmp $ nvm --version
0.25.4 Have you tried the same flow in bash? |
I got mostly what you got
This bit might say something
Any ideas? |
I suspect it's because of |
Nope, downgrading didn't work:
I've also tried with I don't think it is I'm thinking it's something to do with the |
I found the problem. It was because I had the
Note how the nvm version is the same even after going to a different directory. In the previous case, the Bash does do what is expected though, so it's still kind of a bug in the bass version. However, it works for me without Up to you, what you want to do with this 🐛 =) |
Glad to hear it works out! I was able to reproduce it, and the bug was because |
Can bass not do something along the lines of (pseudocode) "if nvm is already sourced, and It's slightly inefficient but not that bad. |
Does fish + bass support sourcing with arguments? if so, I would consider adding (in addition to the |
The short answer is yes. The sourcing is done by bash, so as long as bash supports it, it works. I tested with the following fish function:
Then I modified nvm.sh to add support of @@ -1791,9 +1791,9 @@
elif nvm_rc_version >/dev/null 2>&1; then
nvm install >/dev/null
fi
-elif [ -n "$VERSION" ]; then
+elif [ -n "$VERSION" ] && [ "_$1" != "_--no-use" ]; then
nvm use "$VERSION" >/dev/null
-elif nvm_rc_version >/dev/null 2>&1; then
+elif nvm_rc_version >/dev/null 2>&1 && [ "_$1" != "_--no-use" ]; then
nvm use >/dev/null
fi Now it works flawlessly:
I think it's a pretty good solution! |
Awesome. I'll add it as part of nvm-sh/nvm#972 (and the ordering of |
Great! Thanks, @ljharb! |
Done and released in v0.30.2. |
Great, thanks! |
I noticed that when I create a nvm function, as suggested in the readme, it reverts the currently used node version (from an
.nvmrc
file)ie,
In
.config/fish/functions/nvm.fish
In a directory where I have a
.nvmrc
file withiojs-v2.2.1
and I runwhich is good. But then when I run
nvm current
:It reverts back to my
default
version, which in this case isv4.1.1
. Same for other functions that read the status ofnvm
eg,nvm list
Is there a way to run
current
or other ready only functions without loading the default?The text was updated successfully, but these errors were encountered: