Set default WSL path to distro $HOME #4588

Closed
opened 2026-01-30 23:51:20 +00:00 by claunia · 14 comments
Owner

Originally created by @mveril on GitHub (Oct 22, 2019).

Set default WSL path to distro $HOME

The default path for WSL distros is currently the Windows user path (%USERPROFILE%) but it's may be better to set it to the distro $HOME.

Proposed technical implementation details (optional)

I don't know if it's possible, but ideally in the WslDistroGenerator.cpp the command line should be conditionally set to "wsl.exe -d " + distName if startingDirectory is set in profile.json, "wsl.exe ~ -d " + distName otherwise.
Another possibility is to add a boolean setting UseWSLHome on the wsl profile.json
Thank you.

Originally created by @mveril on GitHub (Oct 22, 2019). # Set default WSL path to distro $HOME The default path for WSL distros is currently the Windows user path (`%USERPROFILE%`) but it's may be better to set it to the distro `$HOME`. # Proposed technical implementation details (optional) I don't know if it's possible, but ideally in the `WslDistroGenerator.cpp` the command line should be conditionally set to `"wsl.exe -d " + distName` if `startingDirectory` is set in `profile.json`, `"wsl.exe ~ -d " + distName` otherwise. Another possibility is to add a boolean setting `UseWSLHome` on the wsl `profile.json` Thank you.
claunia added the Issue-FeatureArea-SettingsResolution-DuplicateProduct-Terminal labels 2026-01-30 23:51:20 +00:00
Author
Owner

@Biswa96 commented on GitHub (Oct 22, 2019):

Two ways:

  1. Add this command in .bashrc file cd ~
    Or
  2. Run this command line wsl -d Ubuntu sh -c "cd ~;exec $SHELL"
@Biswa96 commented on GitHub (Oct 22, 2019): Two ways: 1. Add this command in `.bashrc` file `cd ~` Or 2. Run this command line `wsl -d Ubuntu sh -c "cd ~;exec $SHELL"`
Author
Owner

@mveril commented on GitHub (Oct 22, 2019):

I already set "commandline" : "wsl.exe ~ -d Ubuntu" in my profile.json and it works, but it's a workaround and a standard method should be better.

@mveril commented on GitHub (Oct 22, 2019): I already set `"commandline" : "wsl.exe ~ -d Ubuntu"` in my `profile.json` and it works, but it's a workaround and a standard method should be better.
Author
Owner

@leoniDEV commented on GitHub (Oct 22, 2019):

As said in this issue, you can set the startingDirectory to //wsl$/distro/home/username

@leoniDEV commented on GitHub (Oct 22, 2019): As said in [this issue](https://github.com/microsoft/terminal/issues/2849), you can set the `startingDirectory` to `//wsl$/distro/home/username`
Author
Owner

@mveril commented on GitHub (Oct 22, 2019):

Ok it's another good workaround
Thank you @leoniDEV

@mveril commented on GitHub (Oct 22, 2019): Ok it's another good workaround Thank you @leoniDEV
Author
Owner

@leoniDEV commented on GitHub (Oct 22, 2019):

Anyway I agree with you that the default startingDirectory for WSL should be the $HOME of the WSL user and not the %USERPROFILE% of the Windows user

@leoniDEV commented on GitHub (Oct 22, 2019): Anyway I agree with you that the default `startingDirectory` for WSL should be the `$HOME `of the WSL user and not the `%USERPROFILE%` of the Windows user
Author
Owner

@sivaramn commented on GitHub (Oct 22, 2019):

Anyway I agree with you that the default startingDirectory for WSL should be the $HOME of the WSL user and not the %USERPROFILE% of the Windows user

Agreed, at least going by the principle of DWIM. if we're launching WSL, it should default to normal *nices behaviour of logging into users home directory within wsl, not some other directory

@sivaramn commented on GitHub (Oct 22, 2019): > Anyway I agree with you that the default `startingDirectory` for WSL should be the `$HOME `of the WSL user and not the `%USERPROFILE%` of the Windows user Agreed, at least going by the principle of DWIM. if we're launching WSL, it should default to normal *nices behaviour of logging into users home directory *within* wsl, not some other directory
Author
Owner

@carlos-zamora commented on GitHub (Oct 22, 2019):

Is this the default directory for WSL distros when opening with ConHost?

@carlos-zamora commented on GitHub (Oct 22, 2019): Is this the default directory for WSL distros when opening with ConHost?
Author
Owner

@sivaramn commented on GitHub (Oct 22, 2019):

Is this the default directory for WSL distros when opening with ConHost?

Don't understand. If I login into wsl using putty, mintty or any other terminal software, the shell prompt comes at /home/<userid> that you created at first install of wsl.

In MS terminal, the default seems to be /mnt/c/users/profile or something. This is generally not the default way

@sivaramn commented on GitHub (Oct 22, 2019): > > > Is this the default directory for WSL distros when opening with ConHost? Don't understand. If I login into wsl using putty, mintty or any other terminal software, the shell prompt comes at `/home/<userid>` that you created at first install of wsl. In MS terminal, the default seems to be `/mnt/c/users/profile` or something. This is generally not the default way
Author
Owner

@mveril commented on GitHub (Oct 22, 2019):

Is this the default directory for WSL distros when opening with ConHost?

Don't understand. If I login into wsl using putty, mintty or any other terminal software, the shell prompt comes at /home/<userid> that you created at first install of wsl.

In MS terminal, the default seems to be /mnt/c/users/profile or something. This is generally not the default way

When we launch wsl.exe without ~ argument it's run WSL at the working directory and when we add ~ in the argument list of WSL it's launched at the distro $HOME (/home/<userid>) directory.
If we launch <distro>.exe of a distro downloaded from the store or when we open the distro app from the start menu the directory is also set to $HOME.
I hope I answered to your question @carlos-zamora

@mveril commented on GitHub (Oct 22, 2019): > > Is this the default directory for WSL distros when opening with ConHost? > > Don't understand. If I login into wsl using putty, mintty or any other terminal software, the shell prompt comes at `/home/<userid>` that you created at first install of wsl. > > In MS terminal, the default seems to be `/mnt/c/users/profile` or something. This is generally not the default way When we launch `wsl.exe` without `~` argument it's run WSL at the working directory and when we add `~` in the argument list of WSL it's launched at the distro $HOME (`/home/<userid>`) directory. If we launch `<distro>.exe` of a distro downloaded from the store or when we open the distro app from the start menu the directory is also set to $HOME. I hope I answered to your question @carlos-zamora
Author
Owner

@DHowett-MSFT commented on GitHub (Oct 23, 2019):

It looks like you've got a workaround here. For the rest, we'll track them in /dup #878 and #592

@DHowett-MSFT commented on GitHub (Oct 23, 2019): It looks like you've got a workaround here. For the rest, we'll track them in /dup #878 and #592
Author
Owner

@ghost commented on GitHub (Oct 23, 2019):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost commented on GitHub (Oct 23, 2019): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!
Author
Owner

@chihab commented on GitHub (Sep 8, 2021):

From Terminal Settings (ctrl + ,):

image

Starting directory should be: \wsl$\YOUR_DISTRIB\home\YOUR_USERNAME

You can access the path in Explorer.

@chihab commented on GitHub (Sep 8, 2021): From Terminal Settings (ctrl + ,): ![image](https://user-images.githubusercontent.com/196852/132467618-706f18c0-10c0-4706-8e2b-d3e5ca734ba2.png) Starting directory should be: \\wsl$\YOUR_DISTRIB\home\YOUR_USERNAME You can access the path in Explorer.
Author
Owner

@aress31 commented on GitHub (Mar 24, 2022):

Well, I am facing the same issue, and I launch my VM directly via the wsl command rather than opening a Terminal Profile, there is the workaround of typing wsl --cd ~ but maybe this startDirectory option could be added to wsl.config to not pollute my .bashrc.

@aress31 commented on GitHub (Mar 24, 2022): Well, I am facing the same issue, and I launch my VM directly via the `wsl` command rather than opening a `Terminal Profile`, there is the workaround of typing `wsl --cd ~` but maybe this `startDirectory` option could be added to `wsl.config` to not pollute my `.bashrc`.
Author
Owner

@caioquirino commented on GitHub (Apr 8, 2024):

In my case for Tabby Terminal I had to set it to:
\\wsl.localhost\<distro>\home\<user>

@caioquirino commented on GitHub (Apr 8, 2024): In my case for Tabby Terminal I had to set it to: `\\wsl.localhost\<distro>\home\<user>`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4588