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

Cannot Use Windows EXE From Within WSL 2 #5296

Closed
gaia opened this issue May 29, 2020 · 17 comments
Closed

Cannot Use Windows EXE From Within WSL 2 #5296

gaia opened this issue May 29, 2020 · 17 comments

Comments

@gaia
Copy link
Contributor

gaia commented May 29, 2020

image

  • What's wrong / what should be happening instead:
    explorer.exe should be in path and launch
$ echo $PATH
/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
@therealkenc
Copy link
Collaborator

$ echo $PATH

There are no win32 paths in your $PATH so interop isn't going to find explorer.exe.

@onomatopellan
Copy link

Something is replacing the path. Try this and post the output:

cd ~
grep -i -e 'PATH' .*

@gaia
Copy link
Contributor Author

gaia commented May 29, 2020

image

@onomatopellan
Copy link

I don't see anything weird there. Is that the root user?

@therealkenc
Copy link
Collaborator

Resetting the baseline, there is no appendWindowsPath=false in wsl.conf, right? Also do you happen to be using WSLENV?

You can push through this doing a export PATH=$PATH:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32 in .profile.

But it would be nice to know what happened here for the collective knowledge-base. No guesses from me. The grep was a good stab, thanks onomatopellan. Maybe grep -ril 😏. Actually it would be somewhat weird for something to cleanly sever the Windows paths (and only the Windows paths). Anything possible I guess.

@gaia
Copy link
Contributor Author

gaia commented May 30, 2020

I don't see anything weird there. Is that the root user?

nope. but the root user has the same issue, no win32 in PATH, no explorer.

Resetting the baseline, there is no appendWindowsPath=false in wsl.conf, right? Also do you happen to be using WSLENV?

no /etc/wsl.conf . no windows env variable called WSLENV, if that's what you meant?

You can push through this doing a export PATH=$PATH:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32 in .profile.

this does it.

Maybe grep -ril 😏.

too many results with -ril

happy to get to the bottom of this.

@therealkenc
Copy link
Collaborator

no windows env variable called WSLENV, if that's what you meant?

Yes. If you don't use WSLENV forget I asked.

too many results with -ril

Yeah, wasn't being real serious about that.

What is needed is to figure out what steps happened leading up to you not seeing your Windows paths automatically marshalled into WSL (or being blown away after getting there). I don't have any easy guesses to offer unfortunately.

@wizardnet972
Copy link

wizardnet972 commented May 31, 2020

same for me with node.exe.
node - command not found.

although node is installed in my windows10 computer.
I think something is not right with the path variable.

How to set the $PATH to know the paths in windows?

DESKTOP-BVRD:/tmp/docker-desktop-root/mnt/host/c/Users/myuser# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

@WSLUser
Copy link

WSLUser commented Jun 1, 2020

So I had the paths stripped even with the append option enabled using a custom imported distro automatically set up for WSL2 (though I saw this before on WSL1 before upgrade using Pengwin, FedoraRemix, Ubuntu, etc. from Store). I had also turned case=on and as well as having fstab turned on in /etc/wsl.conf. After manually setting the custom distro to version 2 again (even though in wsl --list --verbose, it shows version 2) and also switching case=off and turning fstab off) then doing a wsl --shutdown, interop worked again (you can immediately notice it because it automatically goes to the windows home instead of linux home when interop is working properly.)

@andradei
Copy link

For it was my .zshenv file that was setting PATH like this:

export PATH="some/paths/here"

instead of

export PATH="some/paths/here:$PATH" (Notice the appended :$PATH at the end)

I didn't know $PATH already had content when WLS2 first started, and that it had precisely the Windows PATHs. So my script was overriding that instead of appending to it.

Hopefully this will help others.

@licanhua
Copy link
Collaborator

licanhua commented Aug 18, 2020

For Debian, /etc/profile contributed to this problem.

Here is the path definition in /etc/profile

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi

You can delete above lines, then wsl --shutdown to restart Debian.

If you would like to keep these lines, you can also append ":$PATH" to each path like below, then wsl --shutdown

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:$PATH"
fi

@therealkenc
Copy link
Collaborator

Was all ready to forward-dupe this one #5779, but it isn't. On Ubuntu (per OP) /etc/profile doesn't unilaterally initialize the $PATH and I guess never has.

image

@12gabriel3
Copy link

I ran into the same issue after upgrading to windows 2004 and WSL2. System32 was in the PATH but I couldn't execute the commands. Running WSL as an administrator solved the issue.

@mcandre
Copy link

mcandre commented Nov 19, 2020

I had a workaround for WSL1, but the dang /proc/version output changed case and broke my grep expression. Added -i to account for WSL2.

@aragon000
Copy link

Resetting the baseline, there is no appendWindowsPath=false in wsl.conf, right? Also do you happen to be using WSLENV?

You can push through this doing a export PATH=$PATH:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32 in .profile.

But it would be nice to know what happened here for the collective knowledge-base. No guesses from me. The grep was a good stab, thanks onomatopellan. Maybe grep -ril 😏. Actually it would be somewhat weird for something to cleanly sever the Windows paths (and only the Windows paths). Anything possible I guess.

It work

@JimmyBringus
Copy link

Resetting the baseline, there is no appendWindowsPath=false in wsl.conf, right? Also do you happen to be using WSLENV?

You can push through this doing a export PATH=$PATH:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32 in .profile.

But it would be nice to know what happened here for the collective knowledge-base. No guesses from me. The grep was a good stab, thanks onomatopellan. Maybe grep -ril 😏. Actually it would be somewhat weird for something to cleanly sever the Windows paths (and only the Windows paths). Anything possible I guess.

Where is ".profile"?

@HeyITGuyFixIt
Copy link

Where is ".profile"?

@JimmyBringus in your home folder. So ~/.profile.

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

Successfully merging a pull request may close this issue.