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

Windows PATH sometimes not loaded when shell is loaded #383

Open
brunt-toast opened this issue Dec 3, 2024 · 1 comment
Open

Windows PATH sometimes not loaded when shell is loaded #383

brunt-toast opened this issue Dec 3, 2024 · 1 comment

Comments

@brunt-toast
Copy link

On some occasions, when I load up a new shell instance, the windows PATH isn't included, despite interop.enabled and interop.appendWindowsPath both set to true in /etc/wsl.conf.

To Reproduce
This error occurs pseudo-randomly when launching a new shell iinstance, but one of the most reliable ways I've found to produce it follows:

  1. Launch a new tmux session
  2. Create a new tmux window (not pane)
  3. Run echo $PATH in window 0; see that windows path is appended. Run cmd.exe /C echo hello world to show that windows binaries can be executed from WSL.
  4. Run echo $PATH in window 1; see that windows path is not appended. Run cmd.exe /C echo hello world to show that windows binaries are not found in PATH.

Expected behavior
Windows' PATH should be appended to the PATH environment variable and Windows' binaries should be executable from within WSL in all new shell instances while the functionality is enabled per /etc/wsl.conf.

Enviroment:

  • Windows build number: 10.0.22631.446
  • Security Software: N/A
  • WSL version 1/2: WSL2
  • ArchWSL version 24.4.28.0
  • ArchWSL Installer type zip clean
  • Launcher version 24042000

Additional context
The shell I'm using is GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu). I have experienced this issue on multiple devices.

@lukaszpiotrluczak
Copy link

lukaszpiotrluczak commented Jan 31, 2025

Please check /etc/profile. There can be something like:

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

This will overrite PATH which was set by interop. In my proper /etc/profile I have:

if [ -z "${WSL_DISTRO_NAME}" ]; then
  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
fi

The -z "${WSL_DISTRO_NAME}" condition ensures that PATH will be not overwriten when is running as WSL Distro.

So basically check if there is no profile, bash, tmux etc. files which will overwrite PATH.

I hope this will help

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