Terminus: How to set home directory for Windows Subsystem for Linux (WSL)?

Created on 5 Jan 2018  路  18Comments  路  Source: Eugeny/terminus

Version: 1.0.0-alpha.38
Platform: win32 10.0.16299

In the settings, I've tried the following options for Terminal>Bash on Window>Working Directory:

  • ~
  • /home/balter

In both cases, the terminal does not open properly. If I leave that setting blank, then the terminal opens properly but drops me into /mnt/c/Users/ariel (my Windows home directory).

Note: "Bash on Window" should probably be (WSL) or at least make Window plural.

Windows Confirmed WSL Bug

Most helpful comment

@Jule- also, until we find the reason, the WSL folks suggest a workaround by invoking wsl.exe ~ or wsl.exe ~ -d <distro-name> - which you can set up as a Profile in Terminus.

All 18 comments

FYI, I added cd ~ at the end of my ~/.bashrc and that works as expected.

Well, there is an infinite number of workarounds in Linux. But WSL is going to be a huge use case for Terminus. MobaXTerm knows how to default to the WSL directory. It would be good if Terminus could too.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two weeks unless you comment.
Thank you for your contributions.

FTR, this is problematic when you have some binaries present in the Windows environnement that can be reached in the WSL environnement.

For example take yarn. I have yarn installed with scoop on Windows and with apt on WSL:
In PowerShell

C:\Users\jule> yarn global bin
C:\Users\jule\scoop\apps\yarn\current\bin

In Terminus

jule@Jule-PC:/mnt/c/Users/jule$ yarn global bin
/mnt/c/Users/jule/C:\Users\jule\scoop\apps\yarn\current/bin

jule@Jule-ZB:/mnt/c/Users/jule/dev$ cd ~

jule@Jule-ZB:~$ yarn global bin
/home/jule/.yarn/bin

And when you modify your .bashrc in order to have yarn binaries in the path like this:

export PATH="$(yarn global bin):$PATH"

Then when your .bashrc is executed in your Windows home directory you will have in your WSL path the first wrong scoop form (/mnt/c/Users/jule/C:\Users\jule\scoop\apps\yarn\current/bin) instead of the second one (/home/jule/.yarn/bin).

Indeed adding cd ~ at the beginning of your .bashrc do the trick like @pinyin said. But it is not natural and putting /home/jule in Terminus working directory setting breaks the terminal. It is still not desirable.

The recent Terminus versions will let you pick a working directory inside WSL rootfs if you're using the "browse" button near the input field. Sorry for not responding in this ticket

Oh ok no problem, thank you for the information.


Don't know which version you are talking about but I have still some issues.

Tested with:

  • Terminus 1.0.1 (1.0.0-alpha.55)
  • Platform: win32 10.0.17134
  • WSL / Default distro
    (don't know the difference with WSL / Legacy but this second one crashes in my case)

For what I have seen:

  • [x] This is right that when I browse I end up in C:\Users\jule\AppData\Local\lxss\rootfs as you mentioned.
  • [ ] But in my case C:\Users\jule\AppData\Local\lxss\rootfs\home is empty. And my ~ is located in C:\Users\jule\AppData\Local\lxss\home\jule. Ok that is misleading but why not and maybe that this is not the case for everyone.
  • [ ] The problem is that whatever I put here when I start a new terminal I am located in / root directory. That is better for my yarn global bin issue but not really what users should expect.

EDIT: I have seen that we are on the alpha.65 version and since there is no auto-update 馃檭 (damn I get used to it so much... Sorry you have done really good work! Keep it that way! 馃槂). So I will come back with fresh version to confirm or not these observations.
EDIT2: 馃帀馃帀馃帀

Adjusted versioning to facilitate autoupdates

Ok I can confirm that whatever I put in working directory setting that is under lxss folder I end up with / as working directory.

And I don't know if it is normal but I have installed last alpha.65 version from github and I still have:

image

On my Windows, WSL distros have their FS in %HOME%\AppData\Local\Packages\[distro]\LocalState\rootfs, and the user's home folder is located inside.

Please try following:

  1. Install an additional WSL distro to see if it gets set up with a "proper" FS layout
  2. Alternatively, try creating an empty home folder at C:\Users\jule\AppData\Local\lxss\rootfs\home\jule and see if setting it as CWD tricks WSL into doing the right thing.

@Jule- also, until we find the reason, the WSL folks suggest a workaround by invoking wsl.exe ~ or wsl.exe ~ -d <distro-name> - which you can set up as a Profile in Terminus.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two weeks unless you comment.
Thank you for your contributions.

This started happening for me after the latest Alpha 78 release. Can't trace what is causing it though
Edit: Using the suggested workaround works fine

@Jule- also, until we find the reason, the WSL folks suggest a workaround by invoking wsl.exe ~ or
wsl.exe ~ -d - which you can set up as a Profile in Terminus.

@Eugeny That work, but it breaks the right click opt for open folder, it forward you right to your ~ directory.

@Jule- also, until we find the reason, the WSL folks suggest a workaround by invoking wsl.exe ~ or wsl.exe ~ -d <distro-name> - which you can set up as a Profile in Terminus.

Excuse me for the naive question: how can I set a custom profile this way?

@Jule- also, until we find the reason, the WSL folks suggest a workaround by invoking wsl.exe ~ or wsl.exe ~ -d <distro-name> - which you can set up as a Profile in Terminus.

Excuse me for the naive question: how can I set a custom profile this way?

Jietu20191220-090029

just add an argument.

@Eugeny
That works.But I found it's has another problem.I set the ubuntu 18.04 as default launching.
And I open a new terminal for ubuntu. It shown the /mnt/c/users/victor.And I set the ubuntu as default launching. It turn back normal. It seems like the profile setting only works for the default launching.

Good news - WSL2 now supports setting any CWD when starting a shell.

  • Make sure you're using a fresh nightly build that includes this fix
  • If using a profile, add a shell: wsl-Ubuntu or similar to its config entry, or just recreate it.
  • Set the working directory as \\wsl$\Ubuntu\home\...
Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcinbojko picture marcinbojko  路  12Comments

helloxz picture helloxz  路  17Comments

naeemrashid picture naeemrashid  路  27Comments

wangxin picture wangxin  路  14Comments

ponsfrilus picture ponsfrilus  路  15Comments