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

WSL2: Strange wsl command execution context #5801

Closed
wclr opened this issue Aug 24, 2020 · 2 comments
Closed

WSL2: Strange wsl command execution context #5801

wclr opened this issue Aug 24, 2020 · 2 comments

Comments

@wclr
Copy link

wclr commented Aug 24, 2020

D:\Code\chartify>wsl --list -v
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  docker-desktop         Running         2

I 'm running the same conmmand node --version using wsl and within wsl and get different results. Seem like wsl [cmd] is run in some different context, not default distro. It is not very expected.

D:\Code\chartify>wsl node --version
v10.19.0

D:\Code\chartify>wsl
alexo@WHITECOLOR-PC:/mnt/d/Code/chartify$
--> node --version
v12.18.3
alexo@WHITECOLOR-PC:/mnt/d/Code/chartify$
-->

image

@therealkenc
Copy link
Collaborator

D:\Code\chartify>wsl node --version

Very likely, you've installed nvm as an unstated part of the repro. That command above is not an interactive shell. Therefore, the node found was not the one in your $HOME/.nvm/... path component added by your .bashrc, because your .bashrc was never fired.

If you wanted equivalence, it would look like:

D:\> wsl.exe /bin/bash -ic 'node --version'

Whatever the specifics, this is Linux-behavior. The node that gets executed is the first one in your $PATH. You would get the same behavior with ssh you@somelinuxbox node --version.

image

@wclr
Copy link
Author

wclr commented Aug 25, 2020

@therealkenc
Thanks! That's what I needed. Couldn't find this in docs.

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

2 participants