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

WSL command from windows not executed in appropriate folder in WSL file system #8585

Closed
1 of 2 tasks
theotherp opened this issue Jul 7, 2022 · 5 comments
Closed
1 of 2 tasks

Comments

@theotherp
Copy link

Version

Microsoft Windows [Version 10.0.19044.1766]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.10.16

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

In windows execute wsl.exe pwd.

Expected Behavior

pwd should print the mounted folder from which the command was excuted. For example running the command from C:\temp should print /mnt/C/temp.

Actual Behavior

I get /, i.e. the wsl command is always executed in the root folder. I forward calls to docker via a custom docker.cmd file but that means that the commands are not executed in the current working directory.

Diagnostic Logs

No response

@benhillis
Copy link
Member

I forward calls to docker via a custom docker.cmd file but that means that the commands are not executed in the current working directory.

Can you please clarify what you mean by this?

@theotherp
Copy link
Author

theotherp commented Jul 7, 2022

  1. Under Windows do cd c:\ (or any other folder)
  2. Run wsl pwd

You'd expect the output to be /c/ but instead it's /. Until a few days ago the working directory WSL was mapped from the windows working directory from where the wsl command was executed.

As for the docker thing... I have a file docker-compose.cmd in my path:

@echo off
c:\windows\system32\wsl.exe -d Ubuntu-20.04 -- %*

That way any command made to this batch file is executed in WSL using the provided parameters. Running this script from c:\temp originally ran it in /mnt/c/temp but now it's run in / and the docker-compose.yml which is in the folder where I ran the script is not found.

@ghost ghost removed the needs-author-feedback label Jul 7, 2022
@elsaco
Copy link

elsaco commented Jul 7, 2022

@theotherp does it work outside docker? Using your script, it works when run in a pwsh session:

PS C:\Temp> cat .\wsl_bug.cmd
@echo off
c:\windows\system32\wsl.exe -d Ubuntu-20.04 -- %*
PS C:\Temp> .\wsl_bug.cmd pwd
/mnt/c/Temp
PS C:\Temp> pwd

Path
----
C:\Temp

PS C:\Temp>

Tested on Windows 10 and

PS C:\Temp> wsl --status
Default Distribution: Jammy
Default Version: 2

Windows Subsystem for Linux was last updated on 3/26/2022
WSL automatic updates are on.

Kernel version: 5.10.102.1

@theotherp
Copy link
Author

It has nothing to do with docker, just running wsl pwd reproduces the problem.

I know it worked a couple of days ago. Since then I installed windows updates and enabled bitlocker for my boot drive.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

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

3 participants