WSL doesn't automatically mount drive letters added by subst command
Windows Version
Microsoft Windows Version (0S Build 22621.1992)
WSL Version
WSL version: 1.2.5.0
Are you using WSL 1 or WSL 2?
- [X] WSL 2
- [X] WSL 1
Kernel Version
5.15.90.1
Distro Version
Ubuntu 20.04
Other Software
No response
Repro Steps
Add your disk in drive letter E:
Then in cmd execute subst D: E:\ subst G: E:\
Wsl doesn't mount D and G at /mnt/d and /mnt/g
Expected Behavior
D: and G: are mounted
Actual Behavior
They are not mounted
Diagnostic Logs
No response
This might need to be a different issue, but I have found that WSL commands (e.g. "ubuntu config --default-user steve") will fail if there is a SUBST drive in the PATH variable. This is a pretty significant issue for me, since I also use VS2022 with VCPKG located on a SUBST drive.
As documented in #12970, not only does WSL not automount subst drives, it is not possible to run wsl.exe commands from subst drives.
Consolidating these subst-related issues here.
For me, I can live with WSL not being able to see or use subst drives, BUT if it's path is derived from the default Windows path in any way, then that derivation should detect and remove and subst drive/path components before providing the result to WSL. That way commands farther down in the path won't fail because WSL tried to search a subst path location.
When I run WSL (Ubuntu default) from a command prompt where my current directory is under a SUBST drive letter, wsl neither mounts the drive nor tries to translate the current directory to match. Then it chooses the linux home folder as the current directory. This makes 2 separate but related problems:
J:\test>subst
J:\: => D:\really\long\windows\folder\path
J:\test>wsl pwd
wsl: Failed to translate 'J:\'
/home/brbill