Not starting in the starting directory specified in the profile #15301

Closed
opened 2026-01-31 04:34:18 +00:00 by claunia · 11 comments
Owner

Originally created by @jerusdp on GitHub (Sep 21, 2021).

Windows Terminal version (or Windows build number)

1.11.2421.0

Other Software

No response

Steps to reproduce

Start Ubuntu 20.4 with a starting directory specified in the profile

Expected Behavior

Starts in the specified profile

Actual Behavior

Starts at the root

Note:
"startingDirectory": null,

Specified in the defaults for profile but I would expect this value to be superseded by the value specified in the specific profile.

Originally created by @jerusdp on GitHub (Sep 21, 2021). ### Windows Terminal version (or Windows build number) 1.11.2421.0 ### Other Software _No response_ ### Steps to reproduce Start Ubuntu 20.4 with a starting directory specified in the profile ### Expected Behavior Starts in the specified profile ### Actual Behavior Starts at the root Note: "startingDirectory": null, Specified in the defaults for profile but I would expect this value to be superseded by the value specified in the specific profile.
Author
Owner

@zadjii-msft commented on GitHub (Sep 21, 2021):

What's the actual startingDirectory you've set? Is it in the \\wsl$\ filesystem? Does manually starting wsl.exe first fix this?

This sounds like that thing where the WSL directory doesn't exist until WSL has been started, but that should have been fixed by the WSL --cd hack we did in 1.11... 🤔

@zadjii-msft commented on GitHub (Sep 21, 2021): What's the actual `startingDirectory` you've set? Is it in the `\\wsl$\` filesystem? Does manually starting `wsl.exe` first fix this? This sounds like that thing where the WSL directory doesn't exist until WSL has been started, but that should have been fixed by the WSL `--cd` hack we did in 1.11... 🤔
Author
Owner

@jerusdp commented on GitHub (Sep 21, 2021):

On the profile the startingDirectory is set to "startingDirectory": "//wsl$/Ubuntu-20.04/home/<username>"

On the default its set to null

@jerusdp commented on GitHub (Sep 21, 2021): On the profile the `startingDirectory` is set to ` "startingDirectory": "//wsl$/Ubuntu-20.04/home/<username>"` On the default its set to `null`
Author
Owner

@zadjii-msft commented on GitHub (Sep 28, 2021):

Does manually starting wsl.exe first fix this?

It's weird that it's starting at the root of the WSL filesystem. Even if the --cd hack didn't work, then I'd expect it to start in like, /mnt/c/Users/<your user> or /mnt/c/Windows/system32 or something like that.

Is there anything in your .bashrc (or whatever shell you're using's config) that calls cd /? That's my only real thought as to why this would open in the root...

@zadjii-msft commented on GitHub (Sep 28, 2021): > Does manually starting `wsl.exe` first fix this? It's weird that it's starting at the _root_ of the WSL filesystem. Even if the `--cd` hack didn't work, then I'd expect it to start in like, `/mnt/c/Users/<your user>` or `/mnt/c/Windows/system32` or something like that. Is there anything in your `.bashrc` (or whatever shell you're using's config) that calls `cd /`? That's my only real thought as to why this would open in the root...
Author
Owner

@jerusdp commented on GitHub (Sep 29, 2021):

Hi Mike,

It happens in the Terminal Preview app only. It is happening in the current version and has been for a 5-6 weeks now.

The starting directory is loaded in terminal 1.10.2383.0 and Vscode correctly starts the terminal in the working directory.

@jerusdp commented on GitHub (Sep 29, 2021): Hi Mike, It happens in the Terminal Preview app only. It is happening in the current version and has been for a 5-6 weeks now. The starting directory is loaded in terminal 1.10.2383.0 and Vscode correctly starts the terminal in the working directory.
Author
Owner

@zadjii-msft commented on GitHub (Sep 29, 2021):

Uh oh. That's not what you want to hear. @DHowett as an fyi since I don't think the --cd hack is behind velocity, it'll roll out to stable in 2 weeks which might start hitting more folks

@zadjii-msft commented on GitHub (Sep 29, 2021): Uh oh. That's not what you want to hear. @DHowett as an fyi since I don't think the `--cd` hack is behind velocity, it'll roll out to stable in 2 weeks which might start hitting more folks
Author
Owner

@Rosefield commented on GitHub (Sep 29, 2021):

As another data point, this is working fine for me on both preview and the dev branch in both wsl2 and wsl1 (on separate computers)

My wsl1 settings are

            {
                "bellStyle": "none",
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu-20.04/root"
            },

and on my other computer with wsl2

            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu-20.04/home/schuyler"
            },
@Rosefield commented on GitHub (Sep 29, 2021): As another data point, this is working fine for me on both preview and the dev branch in both wsl2 and wsl1 (on separate computers) My wsl1 settings are ``` { "bellStyle": "none", "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", "hidden": false, "name": "Ubuntu-20.04", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu-20.04/root" }, ``` and on my other computer with wsl2 ``` { "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", "hidden": false, "name": "Ubuntu-20.04", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu-20.04/home/schuyler" }, ```
Author
Owner

@jerusdp commented on GitHub (Oct 1, 2021):

My settings:

            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl",
                "startingDirectory": "//wsl$/Ubuntu-20.04/home/gorta"
            },

The result remains consistent through a re-install of the terminal preview:
image

@jerusdp commented on GitHub (Oct 1, 2021): My settings: ```json { "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", "hidden": false, "name": "Ubuntu-20.04", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu-20.04/home/gorta" }, ``` The result remains consistent through a re-install of the terminal preview: ![image](https://user-images.githubusercontent.com/47631109/135582228-dd4d5e08-49ae-4881-a15e-a3b7044eba99.png)
Author
Owner

@sabith-th commented on GitHub (Oct 28, 2021):

I'm encountering the same behavior since my terminal app was updated today. It used to start in the directory mentioned in the Ubuntu profile (//wsl$/Ubuntu/home/user) but now it is starting in /.

@sabith-th commented on GitHub (Oct 28, 2021): I'm encountering the same behavior since my terminal app was updated today. It used to start in the directory mentioned in the Ubuntu profile (//wsl$/Ubuntu/home/user) but now it is starting in /.
Author
Owner

@DHowett commented on GitHub (Oct 28, 2021):

Ah, this finally makes sense.

This is one place where the direction of the slashes does matter. We have moved all startingDirectory processing for WSL into, well, WSL.

WSL is misinterpreting the Linux-style // paths and dropping you in /.

Since \\wsl$ is a path specifier on the Windows side, you'll want to change to universally using \s when addressing any Windows path.

This behavior difference is visible outside of Terminal as well:

% wsl --cd //wsl$/Debian/home
duhowett@dhowett-sl:/$ exit

% wsl --cd \\wsl$\Debian\home
duhowett@dhowett-sl:/home$
@DHowett commented on GitHub (Oct 28, 2021): Ah, this finally makes sense. This is one place where the direction of the slashes _does_ matter. We have moved *all* startingDirectory processing for WSL into, well, WSL. WSL is misinterpreting the Linux-style `//` paths and dropping you in `/`. Since `\\wsl$` is a path specifier on the Windows side, you'll want to change to universally using `\`s when addressing any Windows path. This behavior difference is visible outside of Terminal as well: ``` % wsl --cd //wsl$/Debian/home duhowett@dhowett-sl:/$ exit % wsl --cd \\wsl$\Debian\home duhowett@dhowett-sl:/home$ ```
Author
Owner

@sabith-th commented on GitHub (Oct 28, 2021):

Yup, changing it to \\wsl$\Ubuntu\home\user has fixed it.

@sabith-th commented on GitHub (Oct 28, 2021): Yup, changing it to `\\wsl$\Ubuntu\home\user` has fixed it.
Author
Owner

@zadjii-msft commented on GitHub (Oct 28, 2021):

Brilliant! Glad we have a solution to this one. thanks!

@zadjii-msft commented on GitHub (Oct 28, 2021): Brilliant! Glad we have a solution to this one. thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15301