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

Leading backslash in path that includes spaces during --import causes help-text #12383

Closed
1 of 2 tasks
jarrodsfarrell opened this issue Dec 16, 2024 · 11 comments
Closed
1 of 2 tasks
Labels

Comments

@jarrodsfarrell
Copy link

jarrodsfarrell commented Dec 16, 2024

Windows Version

Microsoft Windows [Version 10.0.19045.5247]

WSL Version

2.3.26.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Issue

Origin issue: nix-community/NixOS-WSL#606

wsl --import NixOSTest $env:USERPROFILE\NixOS\ nixos-wsl.tar.gz --version 2
[help-text output]
wsl --import NixOSTest $env:USERPROFILE\NixOS nixos-wsl.tar.gz --version 2
Import in progress, this may take a few minutes.

Another user was able to do it with a leading backslash, so there might be something specific on my machine that's causing this weird behavior.

PowerShell Version: 5.1.19041.5247

Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@jarrodsfarrell
Copy link
Author

Copy link

Diagnostic information
Detected appx version: 2.3.26.0

@elsaco
Copy link

elsaco commented Dec 16, 2024

Didn't repro on WSL 2.4.5:

PS C:\Users\elsaco\Downloads> wsl --import NixOS $env:USERPROFILE\NixOS\ nixos-wsl.tar.gz --version 2
The operation completed successfully.

PS C:\Users\elsaco\Downloads> ls $env:USERPROFILE\NixOS

    Directory: C:\Users\elsaco\NixOS

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          12/15/2024  8:18 PM     2260729856 ext4.vhdx

@jarrodsfarrell
Copy link
Author

@elsaco Weird. But a thing I'm noticing is everyone who offered does not have a space in their USERPROFILE whereas mine does since it's my full name including it's space.

So I picked a path that doesn't contain a space on my other disk.

wsl --import NixOSTest G:\NixOS\ nixos-wsl.tar.gz --version 2
Import in progress, this may take a few minutes.

It's a strange edge-case which I don't think is intentional.

@jarrodsfarrell jarrodsfarrell changed the title Leading backslash in path during --import causes help-text Leading backslash in path that includes spaces during --import causes help-text Dec 16, 2024
Copy link

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs

Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The script will output the path of the log file once done.

If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

Once completed please upload the output files to this Github issue.

Click here for more info on logging
If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@jarrodsfarrell
Copy link
Author

Shoo. Be appeased with the same file: WslLogs-2024-12-15_22-56-27.zip

Copy link

Diagnostic information
Detected appx version: 2.3.26.0

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 16, 2024

@elsaco Weird. But a thing I'm noticing is everyone who offered does not have a space in their USERPROFILE whereas mine does since it's my full name including it's space.

If $USERPROFILE has a space in it, then what you're seeing is unfortunately the expected behavior since that would split the path into two arguments before calling wsl. To work around this the simplest would be always quote arguments that might contain spaces:

wsl --import NixOSTest "$env:USERPROFILE\NixOS\" nixos-wsl.tar.gz --version 2

@jarrodsfarrell
Copy link
Author

jarrodsfarrell commented Dec 17, 2024

@OneBlue That's the thing: I tried that in the various incantations to figure out why the command was failing. I did, verbatim, try:

wsl --import NixOSTest "$env:USERPROFILE\NixOS\" nixos-wsl.tar.gz --version 2

But it still failed. It also seems like PowerShell is a bit intelligent to notice cases like $env:USERPROFILE\NixOS\ should be concat'd as a single string since this invocation (note the missing leading backslash):

wsl --import NixOSTest $env:USERPROFILE\NixOS nixos-wsl.tar.gz --version 2

Will work as expected.

@jarrodsfarrell
Copy link
Author

jarrodsfarrell commented Dec 17, 2024

For posterity, I did expand the variable to my USERPROFILE path. So this incantation will fail as well:

wsl --import NixOSTest "C:\Users\Jarrod Farrell\NixOS\" nixos-wsl.tar.gz --version 2

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

3 participants