microsoft/WSL

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

gsusI commented

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

  1. Navigate to the Relevant Directory:

    • Open a terminal and navigate to the directory where the Docker file is located.
  2. 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
  3. Close All Terminals:

    • After the Docker operation completes, close all open terminal windows to ensure a fresh environment for the next steps.
  4. Open PowerShell (pwsh):

    • Open PowerShell on your Windows system.
  5. 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.
  6. 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.
  7. Verify Directory Path with pwd:

    • Run pwd to confirm that the terminal is in the correct directory. This should return the expected directory path.
  8. 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.

Expected Behavior

  • wslpath -u . result from wsl should match pwd.
  • 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:

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!