WSL: Cannot Use Windows EXE From Within WSL 2

- 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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 17 (2 by maintainers)
For Debian, /etc/profile contributed to this problem.
Here is the path definition in /etc/profile
You can delete above lines, then
wsl --shutdownto restart Debian.If you would like to keep these lines, you can also append “:$PATH” to each path like below, then
wsl --shutdownFor it was my
.zshenvfile that was settingPATHlike this:export PATH="some/paths/here"instead of
export PATH="some/paths/here:$PATH"(Notice the appended:$PATHat 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.
Resetting the baseline, there is no
appendWindowsPath=falsein wsl.conf, right? Also do you happen to be usingWSLENV?You can push through this doing a
export PATH=$PATH:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32in.profile.But it would be nice to know what happened here for the collective knowledge-base. No guesses from me. The
grepwas a good stab, thanks onomatopellan. Maybegrep -ril😏. Actually it would be somewhat weird for something to cleanly sever the Windows paths (and only the Windows paths). Anything possible I guess.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=onand as well as having fstab turned on in/etc/wsl.conf. After manually setting the custom distro to version 2 again (even though inwsl --list --verbose, it shows version 2) and also switchingcase=offand turning fstab off) then doing awsl --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.)