I would've expected this to work regardless. Even though I don't have an X drive, I would have expected it to behave as though I did:
➜ ~ wslpath 'X:\does\not\exist' # `echo $?`does not report an error
/mnt/x/does/not/exist
➜ ~ wslpath -u 'C:\does\not\exist' # `echo $?` does not report an error
/mnt/c/does/not/exist
Although that's my expectation, I'm not saying that's the best solution.
I can't imagine any specific scenarios, but depending on the context, it could be useful to run wslpath in "strict" mode or "lax" mode. Strict would error if the path doesn't exist; lax would always output as though the drive and path existed, unless garbage was passed in (e.g., passing in a UNIX path with -u).
Additional context
Technically, this inconsistency occurs if the drive does exist but it's not mounted in WSL.
Unrelated: In my opinion, the error messages should be more explicit. Instead of printing wslpath: X:\ on error, printing ERROR: wslpath: X:\ does not exist as a Windows path would provide more information for the user to troubleshoot their mistake. See the second paragraph of https://github.com/microsoft/WSL/issues/10084#issuecomment-1742239465 for an example of where it could have helped other users.
Code of Conduct
[X] I agree to follow this project's Code of Conduct
Windows Version
Windows 10
Windows Build Number
19045.3448
WSL Version
WSL 2
Distro Version
Ubuntu 22.04.2 LTS
WSL Utilities Version
4.1.1-1ubuntu1~22.04
Describe the bug
When I use wslpath on Windows drives, I get different output when the drive exists than I do if the drive doesn't exist.
The Windows paths In these examples, I do have a C drive but don't have an X drive.
Steps to Reproduce
Expected behavior
I would've expected this to work regardless. Even though I don't have an X drive, I would have expected it to behave as though I did:
Although that's my expectation, I'm not saying that's the best solution.
I can't imagine any specific scenarios, but depending on the context, it could be useful to run
wslpath
in "strict" mode or "lax" mode. Strict would error if the path doesn't exist; lax would always output as though the drive and path existed, unless garbage was passed in (e.g., passing in a UNIX path with -u).Additional context
Technically, this inconsistency occurs if the drive does exist but it's not mounted in WSL.
Unrelated: In my opinion, the error messages should be more explicit. Instead of printing
wslpath: X:\
on error, printingERROR: wslpath: X:\ does not exist as a Windows path
would provide more information for the user to troubleshoot their mistake. See the second paragraph of https://github.com/microsoft/WSL/issues/10084#issuecomment-1742239465 for an example of where it could have helped other users.Code of Conduct