wslpath -u resolves to Docker WSL bind-mount path instead of expected Ubuntu WSL path in a multi-WSL environment
gsusI opened this issue · 2 comments
Windows Version
Microsoft Windows [Version 10.0.22631.3527]
WSL Version
2.2.1.0
Are you using WSL 1 or WSL 2?
- WSL 2
- WSL 1
Kernel Version
5.15.150.1-microsoft-standard-WSL2
Distro Version
Ubuntu 22.04
Other Software
Docker Desktop 4.29.0 (145265) with WSL2 containers
Repro Steps
-
Navigate to the Relevant Directory:
- Open a terminal and navigate to the directory where the Docker file is located.
-
Run the Docker File:
- Ensure Docker Desktop is running.
- Execute the Dockerfile by running the appropriate Docker command (e.g.,
docker build -t myimage .
).
ARG PHP_VERSION=7.4 FROM php:${PHP_VERSION}-cli # Install necessary packages RUN apt-get update && apt-get install -y git unzip # Install Composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Set the working directory inside the container WORKDIR /app
-
Close All Terminals:
- After the Docker operation completes, close all open terminal windows to ensure a fresh environment for the next steps.
-
Open PowerShell (pwsh):
- Open PowerShell on your Windows system.
-
Navigate to the Affected Directory Using WSL Command:
- In PowerShell, navigate to the affected directory using the command:
wsl
- This command opens the directory within the Docker bind-mount context due to the existing issue.
- In PowerShell, navigate to the affected directory using the command:
-
Manually Change Directory to the Affected Directory:
- Within the WSL environment that opened, manually change to the affected directory using
cd
command to ensure you are in the correct context.
- Within the WSL environment that opened, manually change to the affected directory using
-
Verify Directory Path with
pwd
:- Run
pwd
to confirm that the terminal is in the correct directory. This should return the expected directory path.
- Run
-
Run
wslpath -u .
:- Still in the same directory, run the command:
wslpath -u .
- Observe that the output incorrectly points to the Docker bind-mount directory instead of reflecting the output of
pwd
.
- Still in the same directory, run the command:
Expected Behavior
wslpath -u .
result from wsl should matchpwd
.wsl
from PowerShell should open WSL in the current path as it is, not in the Docker bind-mount.
Actual Behavior
wslpath -u .
incorrectly resolves to a Docker bind-mount path instead of matching the pwd
Diagnostic Logs
No response
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 scipt will output the path of the log file once done.
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:
- wslpath fails when pointed to the current directory with the -u option. (#9606), similarity score: 0.78
- wslpath -u C: returns C: rather than /mnt/c (#7111), similarity score: 0.76
- WSL command from windows not executed in appropriate folder in WSL file system (#8585), similarity score: 0.75
- Change WLS to mount at /home path directly (#10133), similarity score: 0.75
- WSL2 start folder is
/mnt/wsl/docker-desktop-bind-mounts/.../mnr/c/Users/me
instead of/mnt/c/Users/me
(#6464), similarity score: 0.74
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
This issue has been automatically closed since it has not had any author activity for the past 7 days. If you're still experiencing this issue please re-file it as a new issue.
Thank you!