-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Minor issue: nvm current
returns blank/nothing on Windows w/ Git Bash environment
#3162
Comments
What happens if you run |
Results of
|
That seems to be working properly, at least. Can you try updating to v0.39.4 and see if that fixes it? |
Updated to v0.39.4 and then subsequently v0.39.5 with a new, but still incorrect, result. $ nvm current
none
|
Presumably
|
It does indeed. I attempted this with a few node versions that I have installed with nvm and saw the same results. Here's the requested output: $ nvm_ls_current
none
$ command which node
/c/Users/jschilling/.nvm/versions/node/v18.13.0/bin/node
$ nvm_version_dir iojs
/c/Users/jschilling/.nvm/versions/io.js
$ node --version
v18.13.0 |
Thanks, that's helpful. What about |
The output from the requested command is: $ nvm_tree_contains_path ${NVM_DIR} $(command which node) ; echo $?
0 |
I think I found a solution, which was in Broken: Working: In my case, 20.10.0 wasn't installed, so it couldn't load it. |
I don't have a My # Load nvm and nvm bash_completion
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion Checking the installed versions confirms the versions listed in the $ ls ~/.nvm/versions/node/
v12.19.1/ v12.20.2/ v16.17.0/ v18.13.0/ The right version is selected after I run |
Indeed, versions shouldn't be hardcoded like that. I haven't had a chance to look into this yet, but it's clearly a Windows-specific bug that needs fixing. If someone beats me to it, I'd love to review a PR. |
I'm doing some research and this seems like it might be a winpty bug, which is part of git bash. Specifically: VERSION="1.2.3"
echo "$VERSION" # prints out 1.2.3
VERSION="$(echo 4.5.6)"
echo "$VERSION" # prints out 4.5.6
node --version 2>/dev/null # prints out whatever the version is
VERSION="$(node --version 2>/dev/null)"
echo "$VERSION" # prints nothing, the var is blank I'm not sure how to fix this exactly, or how to use |
I think I found a solution to your example above. In reference to this SO post, we need to call the node exe explicitly. They mention also that they tried using I tested it using the example you posted above (with version 18.13.0 selected in my git bash session). Results: node --version # prints v18.13.0
VERSION="$(node --version)"
echo $VERSION # prints nothing
VERSION="$(node.exe --version)"
echo $VERSION # prints v18.13.0 I'm not familiar with the codebase for nvm-sh but if someone knows it better, you might be able to update it quicker. I'll poke around in there to see if I can glean where this type of change would need to go. |
interesting, thanks. i'll see what's achievable there, since it'd have to be done only for git bash |
Operating system and version:
Windows 10, nvm version 0.39.1
nvm debug
output:nvm ls
output:How did you install
nvm
?From the install script in the readme
What steps did you perform?
What happened?
Nvm and the node versions installed as expected, however running the
nvm current
command returns nothing/blank in a Windows 10 & Git Bash environment. It even returns blank in thenvm debug
results posted above.Also
nvm list
andnvm ls
don't notate the currently selected version of Node from the list of installed versions.What did you expect to happen?
Similar to how it operates in our MacOS environments, I would expect
nvm current
to show the currently selected Node version andnvm list
andnvm ls
to notate the currently selected Node version from the list of installed versions.Is there anything in any of your profile files that modifies the
PATH
?Not that I can see. The
.bashrc
file alters the NVM_DIR variable and exports it but that is all.The text was updated successfully, but these errors were encountered: