Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Change WLS to mount at /home path directly #10133

Closed
1 of 2 tasks
CleanHit opened this issue May 24, 2023 · 5 comments
Closed
1 of 2 tasks

Change WLS to mount at /home path directly #10133

CleanHit opened this issue May 24, 2023 · 5 comments

Comments

@CleanHit
Copy link

Windows Version

Microsoft Windows [Version 10.0.22621.1702]

WSL Version

1.2.5.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

5.15.90.1

Distro Version

Ubuntu 22.04

Other Software

Linux Docker version 24.0.0, build 98fdcd7
Visual Studio Code 1.78.2
Remote-WSL Extension 0.78.7
Remote Development 0.24.0

Docker image uses Dev Containers 0.288.1 in VS Code 1.77.3

Repro Steps

The process executes a script that I'm not allowed to post here. It invokes docker commands. I have

[boot]
systemd=true
[automount]
root=/

In my /etc/wsl.conf file.

Expected Behavior

The path in the command Start: Run: wsl -d Ubuntu-22.04 -e /bin/sh -c cd '/c/home/<path_to_project>' && /bin/sh should be /home/<path_to_project>. Without appending /c prefix to /home path everything would work.

Actual Behavior

I'm using a WSL2 Ubuntu 22.04 container on my Window 11 2H22 machine with systemd enabled and Docker installed inside. When the docker commands get executed, I get:

[70 ms] Dev Containers 0.288.1 in VS Code 1.77.3 (704ed70d4fd1c6bd6342c436f1ede30d1cff4710).
[69 ms] Start: Resolving Remote
[279 ms] Start: Run: wsl -l -v
[521 ms] Start: Run: wsl -d Ubuntu-22.04 -e wslpath -u /home/<path_to_project>
[930 ms] Start: Run: wsl -d Ubuntu-22.04 -e /bin/sh -c cd '/c/home/<path_to_project>' && /bin/sh
[945 ms] Start: Run in host: id -un
[1327 ms] Shell server terminated (code: 2, signal: null)

/bin/sh: 1: cd: can't cd to /c/home/<path_to_project>

The script fails because the WSL command appends /c prefix to /home path in the command Start: Run: wsl -d Ubuntu-22.04 -e /bin/sh -c cd '/c/home/<path_to_project>' && /bin/sh

Diagnostic Logs

No response

@Biswa96
Copy link

Biswa96 commented May 24, 2023

Without appending /c prefix to /home path everything would work.

The root=/ option does not change the home directory path of the current user in Linux distribution. It changes the Windows' partition mount path in Linux distribution. For example, /mnt/c/ becomes /c/. More information can be found here https://learn.microsoft.com/en-us/windows/wsl/wsl-config

@CleanHit
Copy link
Author

CleanHit commented May 24, 2023

Thank you @Biswa96, I've read this doc. However, I couldn't find the required steps / setup to ensure that the path resolves directly at /home and not at /mnt/c/ or /c/.

Am I missing something? Is this even possible?

@CleanHit CleanHit changed the title Change WLS home path Change WLS to mount at /home path directly May 24, 2023
@Biswa96
Copy link

Biswa96 commented May 24, 2023

Am I missing something?

That option in wsl.conf is not related to move or mount /home directory. There are some ways to move /home directory in Windows, for example creating a symbolic link from /home -> /c/home. But I would not suggest to do that because modifying any file in that directory using Windows program will loose the file metadata (user permission, timestamp etc.).

@elsaco
Copy link

elsaco commented May 24, 2023

@CleanHit the id -un command failed, unless you removed the output:

[945 ms] Start: Run in host: id -un
[1327 ms] Shell server terminated (code: 2, signal: null)

and then cd failed:

/bin/sh: 1: cd: can't cd to /c/home/<path_to_project>

What is the output of id -un when manually run? It should be your path_to_project, whatever that resolves to.

@CleanHit
Copy link
Author

CleanHit commented May 30, 2023

@elsaco running id -un output only my username and not the complete path to my project.

@microsoft microsoft locked and limited conversation to collaborators Jun 13, 2023
@OneBlue OneBlue converted this issue into discussion #10192 Jun 13, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants