WSL default directory forced to windows filesytem #12427

Closed
opened 2026-01-31 03:15:21 +00:00 by claunia · 7 comments
Owner

Originally created by @aarware on GitHub (Feb 5, 2021).

There seems to be no way to set the default directory to the root or any directory under the wsl file system.

No mater what I use for "startingDirectory" it always resolves to
/mnt/c/<startingDirectory>

I have tried using

  • "" converts to /mnt/c/windows/system32
  • "/" converts to /mnt/c
  • "~" converts to current windows user home directory
  • "/home/<my linux user>" converts to current windows user home directory

This is the current settings I have for the wsl terminal

{
  "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
  "hidden": false,
  "name": "Ubuntu-20.04",
  "source": "Windows.Terminal.Wsl",
  "startingDirectory": "~",
  "tabColor":"#d35115"
   }
Originally created by @aarware on GitHub (Feb 5, 2021). There seems to be no way to set the default directory to the root or any directory under the wsl file system. No mater what I use for "**startingDirectory**" it always resolves to `/mnt/c/<startingDirectory>` I have tried using - "" converts to /mnt/c/windows/system32 - "/" converts to /mnt/c - "~" converts to current windows user home directory - "/home/\<my linux user\>" converts to current windows user home directory This is the current settings I have for the wsl terminal ``` { "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}", "hidden": false, "name": "Ubuntu-20.04", "source": "Windows.Terminal.Wsl", "startingDirectory": "~", "tabColor":"#d35115" } ```
claunia added the Needs-TriageNeeds-Tag-Fix labels 2026-01-31 03:15:21 +00:00
Author
Owner

@LuanVSO commented on GitHub (Feb 5, 2021):

the starting path is always a windows path. use this:

"startingDirectory": "\\\\wsl$\\<distro name>\\<wsl path>",
@LuanVSO commented on GitHub (Feb 5, 2021): the starting path is always a windows path. use this: ```json "startingDirectory": "\\\\wsl$\\<distro name>\\<wsl path>", ```
Author
Owner

@aarware commented on GitHub (Feb 5, 2021):

Thanks for the fast response.
Seems weird, if you open the linux shell directly the starting path is not windows file system but linux and functions as one would expect, so I don't understand why this would be coded to force it to windows file system, seems a bit counterintuitive.

I tired the suggestion "assuming i did it right", still does not work

I tried

  • "startingDirectory": "\\wsl$\\Ubuntu-20.04\\~"
  • "startingDirectory": "\\wsl$\\Ubuntu-20.04"
  • "startingDirectory": "\\wsl$"
  • "startingDirectory": "wsl$"

Thanks

@aarware commented on GitHub (Feb 5, 2021): Thanks for the fast response. Seems weird, if you open the linux shell directly the starting path is not windows file system but linux and functions as one would expect, so I don't understand why this would be coded to force it to windows file system, seems a bit counterintuitive. I tired the suggestion "assuming i did it right", still does not work I tried - "startingDirectory": "\\\\wsl$\\\\Ubuntu-20.04\\\\~" - "startingDirectory": "\\\\wsl$\\\\Ubuntu-20.04" - "startingDirectory": "\\\\wsl$" - "startingDirectory": "wsl$" Thanks
Author
Owner

@LuanVSO commented on GitHub (Feb 5, 2021):

did you escape the 2 backslashes at the start of the path in the json? it has to be \\\\ because \\ is interpreted as \

@LuanVSO commented on GitHub (Feb 5, 2021): did you escape the 2 backslashes at the start of the path in the json? it has to be `\\\\` because `\\` is interpreted as `\`
Author
Owner

@sarim commented on GitHub (Feb 5, 2021):

try this:

"startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\home\\username"

put your ubuntu username in username.

@sarim commented on GitHub (Feb 5, 2021): try this: ```json "startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\home\\username" ``` put your ubuntu username in `username`.
Author
Owner

@Don-Vito commented on GitHub (Feb 7, 2021):

@aarware

@Don-Vito commented on GitHub (Feb 7, 2021): @aarware * The original discussion is 2-years old and can be found here: https://github.com/microsoft/terminal/issues/592. * More recent discussion of how to write the path correctly is here: https://github.com/microsoft/terminal/issues/5377#issuecomment-614724488
Author
Owner

@DHowett commented on GitHub (Feb 12, 2021):

Thanks @Don-Vito. This looks like a rehash of 592/5377 plus a little bit of "sometimes WSL doesn't do the right thing." We're working on it, and we think the solution we're working on will make it better even in case WSL doesn't start up the network share.

@DHowett commented on GitHub (Feb 12, 2021): Thanks @Don-Vito. This looks like a rehash of 592/5377 plus a little bit of "sometimes WSL doesn't do the right thing." We're working on it, and we think the solution we're working on will make it better even in case WSL doesn't start up the network share.
Author
Owner

@aarware commented on GitHub (Feb 12, 2021):

Sorry for the late response, Thanks @sarim and @LuanVSO that was it, I just did not have the "wsl path" as home\\username.

I still think its strange for the default to open the windows user root, nevertheless, Thanks to all for making this I definitely will get a lot of use of it.

@aarware commented on GitHub (Feb 12, 2021): Sorry for the late response, Thanks @sarim and @LuanVSO that was it, I just did not have the "wsl path" as home\\\username. I still think its strange for the default to open the windows user root, nevertheless, Thanks to all for making this I definitely will get a lot of use of it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12427