WSL from WT starts in root directory instead the user HOME #15952

Closed
opened 2026-01-31 04:53:12 +00:00 by claunia · 13 comments
Owner

Originally created by @angelog0 on GitHub (Nov 23, 2021).

Windows Terminal version

1.11.2921.0

Windows build number

19044.1387

Other Software

No response

Steps to reproduce

After the upgrade from Win 10 pro 21H1 to 21H2, when I start WSL2 from WT it has as starting directory the root (/) but they are years that in my settings.json file I have:

{
                "guid": "{2c4gd342-38b7-51cf-b940-2309a097f518}",
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu/home/angelog",
               ...
            },

Expected Behavior

It should have $HOME as starting directory

Actual Behavior

See the above steps to reproduce...

Originally created by @angelog0 on GitHub (Nov 23, 2021). ### Windows Terminal version 1.11.2921.0 ### Windows build number 19044.1387 ### Other Software _No response_ ### Steps to reproduce After the upgrade from Win 10 pro 21H1 to 21H2, when I start WSL2 from WT it has as starting directory the root (`/`) but they are years that in my `settings.json` file I have: ``` { "guid": "{2c4gd342-38b7-51cf-b940-2309a097f518}", "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu/home/angelog", ... }, ``` ### Expected Behavior It should have $HOME as starting directory ### Actual Behavior See the above steps to reproduce...
Author
Owner

@angelog0 commented on GitHub (Nov 23, 2021):

How to fix this! It is very annoying!!!

@angelog0 commented on GitHub (Nov 23, 2021): How to fix this! It is very annoying!!!
Author
Owner

@zadjii-msft commented on GitHub (Nov 23, 2021):

I'm pretty sure they changed the path of the WSL mount. I think if you change it to

            {    
                "guid": "{2c4gd342-38b7-51cf-b940-2309a097f518}",
                "name": "Ubuntu",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl.localhost/Ubuntu/home/angelog",
            },

it should work

See: https://github.com/microsoft/WSL/issues/6995#issuecomment-934115519

@zadjii-msft commented on GitHub (Nov 23, 2021): I'm pretty sure they changed the path of the WSL mount. I think if you change it to ```json { "guid": "{2c4gd342-38b7-51cf-b940-2309a097f518}", "name": "Ubuntu", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl.localhost/Ubuntu/home/angelog", }, ``` it should work See: https://github.com/microsoft/WSL/issues/6995#issuecomment-934115519
Author
Owner

@angelog0 commented on GitHub (Nov 23, 2021):

@zadjii-msft, I tried that but it does not work. This works:

"startingDirectory": "\\\\wsl$\\Ubuntu\\home\\angelog",

I used WSL2 in WT frequently these days but just today the issue comes out, after the upgrade to 21H2 in Win 10 Pro.

@angelog0 commented on GitHub (Nov 23, 2021): @zadjii-msft, I tried that but it does not work. This works: ``` "startingDirectory": "\\\\wsl$\\Ubuntu\\home\\angelog", ``` I used WSL2 in WT frequently these days but just today the issue comes out, after the upgrade to 21H2 in Win 10 Pro.
Author
Owner

@DHowett commented on GitHub (Nov 23, 2021):

Ah, yes, backslashes are now required.

@DHowett commented on GitHub (Nov 23, 2021): Ah, yes, backslashes are now _required_.
Author
Owner

@DHowett commented on GitHub (Nov 23, 2021):

If WSL sees forward slashes, it will try to parse it as a Linux-side path. :|

@DHowett commented on GitHub (Nov 23, 2021): If WSL sees forward slashes, it will try to parse it as a Linux-side path. :|
Author
Owner

@zadjii-msft commented on GitHub (Nov 23, 2021):

Ah right, forgot about that one. So, presumably, /home/angelog should also work, without all the other Windows-esqe path machinations at the start.

@zadjii-msft commented on GitHub (Nov 23, 2021): Ah right, forgot about that one. So, presumably, `/home/angelog` should also work, without all the other Windows-esqe path machinations at the start.
Author
Owner

@angelog0 commented on GitHub (Nov 23, 2021):

It seems that this works:

"startingDirectory": "/home/angelog",

The solution is always simpler than it seems!

@angelog0 commented on GitHub (Nov 23, 2021): It seems that this works: ``` "startingDirectory": "/home/angelog", ``` The solution is always simpler than it seems!
Author
Owner

@WeetA34 commented on GitHub (Dec 20, 2021):

Hello,
It's also the same starting Windows 10 21H1 Cumulative Update 2021-12

@WeetA34 commented on GitHub (Dec 20, 2021): Hello, It's also the same starting Windows 10 21H1 Cumulative Update 2021-12
Author
Owner

@phil-blain commented on GitHub (Jan 14, 2022):

Hi, I'm still on 1909 (Microsoft Windows [version 10.0.18363.1916]) and recently upgraded Windows Terminal from 1.5.10411.0 to 1.11.3471.0 (the latest).

If my WSL 2 machine is already running, either of these work to start in my linux HOME:

"startingDirectory": "//wsl$/Ubuntu-20.04/home/philippe/"
// or
"startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\home\\philippe\\"

If the machine is not already running though, neither of those work, and WSL completely fails to launch. With WT 1.5, I used to end up in %USERPROFILE% (/mnt/c/Users/WIN_USERNAME) upon first launch, and in $HOME afterwards, as long as the WSL VM was still running.

I understand that it's probably a WSL bug if accessing the P9 server when the VM is not yet running does not launch the VM (which from my understanding is why WSL fails to launch), but I prefered the previous behaviour of falling back to %USERPROFILE% upon first launch, since then at least WSL could launch... Could there be a way for this fallback behaviour to come back to WT, while the WSL team sorts the P9 access bug ?

@phil-blain commented on GitHub (Jan 14, 2022): Hi, I'm still on 1909 (Microsoft Windows [version 10.0.18363.1916]) and recently upgraded Windows Terminal from 1.5.10411.0 to 1.11.3471.0 (the latest). If my WSL 2 machine is _already running,_ either of these work to start in my linux HOME: ```json "startingDirectory": "//wsl$/Ubuntu-20.04/home/philippe/" // or "startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\home\\philippe\\" ``` If the machine is not already running though, neither of those work, and WSL completely fails to launch. With WT 1.5, I used to end up in `%USERPROFILE%` (`/mnt/c/Users/WIN_USERNAME`) upon first launch, and in `$HOME` afterwards, as long as the WSL VM was still running. I understand that it's probably a WSL bug if accessing the P9 server when the VM is not yet running does not launch the VM (which from my understanding is why WSL fails to launch), but I prefered the previous behaviour of falling back to `%USERPROFILE%` upon first launch, since then at least WSL could launch... Could there be a way for this fallback behaviour to come back to WT, while the WSL team sorts the P9 access bug ?
Author
Owner

@phil-blain commented on GitHub (Jan 14, 2022):

Sorry for the disturbance, it turns out I had already found a workaround (https://github.com/microsoft/WSL/issues/6995#issuecomment-967624800): instead of using startingDirectory, changing the command line instead works:

"commandline": "wsl.exe ~ -d Ubuntu-20.04"
@phil-blain commented on GitHub (Jan 14, 2022): Sorry for the disturbance, it turns out I had already found a workaround (https://github.com/microsoft/WSL/issues/6995#issuecomment-967624800): instead of using `startingDirectory`, changing the command line instead works: ```json "commandline": "wsl.exe ~ -d Ubuntu-20.04" ```
Author
Owner

@uche-madu commented on GitHub (Jul 24, 2023):

To anyone having this problem now with no resolution yet, I just resolved mine by running ubuntu.exe config --default-user username in Powershell

@uche-madu commented on GitHub (Jul 24, 2023): To anyone having this problem now with no resolution yet, I just resolved mine by running `ubuntu.exe config --default-user username` in Powershell
Author
Owner

@pranav-chandrode commented on GitHub (Aug 27, 2023):

Only this worked for me.
Thank you!

@pranav-chandrode commented on GitHub (Aug 27, 2023): > Only this worked for me. Thank you!
Author
Owner

@neves-lucas commented on GitHub (Nov 10, 2023):

To anyone having this problem now with no resolution yet, I just resolved mine by running ubuntu.exe config --default-user username in Powershell

Thanks, that was the only way to fix it for me.

@neves-lucas commented on GitHub (Nov 10, 2023): > To anyone having this problem now with no resolution yet, I just resolved mine by running `ubuntu.exe config --default-user username` in Powershell Thanks, that was the only way to fix it for me.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15952