Skip to content
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

Set default WSL path to distro $HOME #3286

Closed
mveril opened this issue Oct 22, 2019 · 14 comments
Closed

Set default WSL path to distro $HOME #3286

mveril opened this issue Oct 22, 2019 · 14 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@mveril
Copy link

mveril commented 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.

@mveril mveril added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Oct 22, 2019
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Oct 22, 2019
@mveril mveril changed the title Set default WSL path to distro home Set default WSL path to distro $HOME Oct 22, 2019
@Biswa96
Copy link

Biswa96 commented 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"

@mveril
Copy link
Author

mveril commented 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.

@leoniDEV
Copy link

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

@mveril
Copy link
Author

mveril commented Oct 22, 2019

Ok it's another good workaround
Thank you @leoniDEV

@leoniDEV
Copy link

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

@sivaramn
Copy link

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

@carlos-zamora carlos-zamora added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. and removed Needs-Tag-Fix Doesn't match tag requirements labels Oct 22, 2019
@carlos-zamora
Copy link
Member

carlos-zamora commented Oct 22, 2019

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

@sivaramn
Copy link

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

@mveril
Copy link
Author

mveril commented 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

@DHowett-MSFT
Copy link
Contributor

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

@ghost
Copy link

ghost commented 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 ghost closed this as completed Oct 23, 2019
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 23, 2019
@chihab
Copy link

chihab commented 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.

@aress31
Copy link

aress31 commented 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.

@caioquirino
Copy link

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

9 participants