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

wslpath -u C: returns C: rather than /mnt/c #7111

Closed
1 of 2 tasks
deliverystack opened this issue Jun 23, 2021 · 6 comments
Closed
1 of 2 tasks

wslpath -u C: returns C: rather than /mnt/c #7111

deliverystack opened this issue Jun 23, 2021 · 6 comments
Labels

Comments

@deliverystack
Copy link

Windows Build Number

21390.2025

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.16

Distro Version

Ubuntu 20.24

Other Software

No response

Repro Steps

$ file which wslpath
/usr/bin/wslpath: symbolic link to /init

$ wslpath -u "C:\"
/mnt/c/

$ wslpath -u "C:"
C:

Expected Behavior

wslpath -u "C:" returns /mnt/c

Actual Behavior

wslpath -u "C:" returns "C:"

Diagnostic Logs

No response

@therealkenc
Copy link
Collaborator

Effectively #4908. Different under the premise drives are special paths.

@deliverystack
Copy link
Author

deliverystack commented Jun 25, 2021

@therealkenc Disagree, I don't see this as a feature request for missing paths, but as a defect correction for existing paths. C: and C:\ cannot be not equivalent except for the trailing slash or backslash.

@craigloewen-msft
Copy link
Member

Hi @deliverystack this is currently expected behaviour. Currently as wslpath is implemented the string C: is not seen as an existing file but C:\ is.

Is there a scenario that you're blocked with from this behaviour? Or anything that it's breaking for you?

In the meantime I'll close this issue out as 'by design' for our tracking but am happy to follow up on this thread, and am tracking #4908 to improve wslpath for scenarios like this.

Thanks!

@deliverystack
Copy link
Author

Thanks, I am not blocked, I can just add the trailing backslash on C:\ in my code or workaround it otherwise, but it is unpredicted and inconsistent behavior that may affect other projects. I think at the very least it might appear as a note in help for the command, or if passed -u [A-Za-z]:[^\\/], as from my perspective, C: exists and is equivalent to C:, the only difference is the slash token.

@craigloewen-msft
Copy link
Member

Got it! That sounds very reasonable to me, I'll keep it tracked in 4908 as part of general improvements there. Thanks for the feedback :)

@NathanielPerryAtAwatoXello

This is an issue when using wslpath in combination with Environment Variables in cases where a user needs to refer to the home or system drive. Both of these values are set to simply C: in the environment variables, so this is a problem:

  • wslpath $( wslvar HOMEDRIVE ) - Actual: C: - Expected: /mnt/c/
  • wslpath $( wslvar SystemDrive ) - Actual: C: - Expected: /mnt/c/

Yes, you could append the slash to the variable, but I don't think that is a reasonable solution because we don't know what odd values HOMEDRIVE or other default environment variables might be set to that could cause problems with appending a slash.

It would be reasonable to expect this to work mkdir -p $( wslpath $( wslvar HOMEDRIVE ) )/projects/some-specific-project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants