terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Changing Ubuntu WSL starting directory keeps it set to the defualt

Open Fishing4Bytes opened this issue 7 years ago • 78 comments

When editing the the settings, I have tried to chang the default starting directory for the Ubuntu WSL Terminal profile as follows "startingDirectory": "/mnt/D/Folder/SubFolder/", and while it doesnt cause any issues or causes the Terminal to resort to default configuration, it does not set the default starting directory to the specified path.

Also it seems that most settings for the profile do literally nothing when changing them, from color, to acrylic or scheme settings.

Note: changing the setting for power shell, cmd, of Kali-Linux does work and change things respectively

Fishing4Bytes avatar Sep 13 '19 01:09 Fishing4Bytes

startingDirectory Should be a windows path, not a *nix path. Try D:\Folder\SubFolder instead.

Could you be specific which settings don't seem to work for that profile? Maybe share the profile from the profiles.json file?

zadjii-msft avatar Sep 13 '19 15:09 zadjii-msft

@zadjii-msft Just checked into this & verified that, yes, specifying a Windows path does work, and for WSL distros, specifying a Windows-relative path to a distro also works.

For example, \\\\wsl$\Ubuntu\home\\rich\\ opens my Ubuntu home folder! 😁

bitcrazed avatar Sep 13 '19 22:09 bitcrazed

This is a duplicate of another bug in the db somewhere. We need to clarify in the documentation that startingDirectory is a Windows path, and since Terminal doesn't actually know anything about the connected application on the other end we can't assume that it's WSL and do path translation and all that stuff.

It's gotta be a Windows path. :smile:

I'm re-tagging this with Issue-Docs

DHowett-MSFT avatar Sep 14 '19 16:09 DHowett-MSFT

I am working on submitting a PR to add that bit of detail, if that is alright with everyone.

MEXdave1997 avatar Sep 19 '19 16:09 MEXdave1997

Sure!

DHowett-MSFT avatar Sep 19 '19 16:09 DHowett-MSFT

@zadjii-msft Just checked into this & verified that, yes, specifying a Windows path does work, and for WSL distros, specifying a Windows-relative path to a distro also works.

For example, \\\\wsl$\Ubuntu\home\\rich\\ opens my Ubuntu home folder! 😁

You may want to use wsl -l first, in order to determine which Ubuntu version you are running. For example: "startingDirectory": "\\\\wsl$\\Ubuntu-18.04\\home\\[linux-user]"

contento avatar Nov 06 '19 20:11 contento

non-escaped also works:

"startingDirectory" : "//wsl$/Ubuntu-18.04/home/<user>"

jgroom33 avatar Feb 09 '20 16:02 jgroom33

The problem isn't the documentation, it's the default JSON provided. That's why everyone keeps complaining about the same thing. Here's mine:

        "startingDirectory" : "\\\\wsl$\\Debian\\home\\<linuxuser>"

which instead takes me to /mnt/c/Users/<windowsuser>. So it looks like that string is entirely ignored and a default that has nothing to do with it is picked. It's not even the same username.

Boobies avatar Feb 27 '20 01:02 Boobies

@Boobies weirdly enough, I've used "startingDirectory": "\\\\wsl$\\Ubuntu\\home\\[linux username]" in my config for a while now with no issue. Could there be any other setting that might be conflicting with it?

MEXdave1997 avatar Feb 27 '20 06:02 MEXdave1997

I've tried all of these and it still seems to be defaulting to c/Users/{user} as well. Any suggestions?

amykapernick avatar Feb 27 '20 22:02 amykapernick

I've tried all of these and it still seems to be defaulting to c/Users/{user} as well. Any suggestions?

start by using this -> //wsl$/Ubuntu/ and then recursively find the directory where you want to go. If you wanna change drives like go to D:/ its not picking up, moreover you can change to your starting directory whose write access is done by root. Check the folder permission also by using ls -l if its root it can be your startingDirectory else not possible right now

kybrdbnd avatar Mar 01 '20 14:03 kybrdbnd

@bitcrazed

For example, \\wsl$\Ubuntu\home\rich\ opens my Ubuntu home folder! 😁

I did this, and it works for me, but now I get this message every time I create a new window

wslpath: '\\wsl$\WLinux\home\tnguyen14'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
C:\Users\NguyenTri

It still cd to the right directory though. Is this error message expected? Any way I can fix it?

tnguyen14 avatar Mar 30 '20 14:03 tnguyen14

@tnguyen14 what commandline are you using to launch wsl?

zadjii-msft avatar Mar 30 '20 14:03 zadjii-msft

@zadjii-msft The Windows Terminal app - is that what you meant?

tnguyen14 avatar Mar 30 '20 16:03 tnguyen14

I meant the commandline in your profiles.json file - could you share that with me?

zadjii-msft avatar Mar 30 '20 16:03 zadjii-msft

It's not specified. Here's the profile object:

        {
            "guid": "{7f586916-8357-53d4-bb2b-ca96f639898a}",
            "hidden": false,
            "name": "WLinux",
            "source": "Windows.Terminal.Wsl",
            "fontSize": 10,
            "fontFace": "SauceCodePro NF",
            "startingDirectory": "//wsl$/WLinux/home/tnguyen14",
            "padding": "0, 0, 0, 0"
        },

tnguyen14 avatar Mar 30 '20 16:03 tnguyen14

Okay, well that's exactly what I'd expect that to look like. I'm not sure why that error message is getting displayed, but you might be able to get answers over at https://github.com/microsoft/WSL

zadjii-msft avatar Mar 30 '20 17:03 zadjii-msft

This is because wslu, the WSL integration bridge that ships with Ubuntu, is running cmd.exe on startup. There's nothing we can do about that. This will happen any time WSL is started outside of the Windows filesystem.

DHowett-MSFT avatar Mar 30 '20 17:03 DHowett-MSFT

More info here: https://github.com/microsoft/terminal/issues/4214

DHowett-MSFT avatar Mar 30 '20 17:03 DHowett-MSFT

@DHowett-MSFT Interesting. I don't see if from windows when I use other terminal apps, like wsltty or the default Pengwin app - is that launched differently somehow?

tnguyen14 avatar Mar 30 '20 18:03 tnguyen14