0

I have Ubuntu installed on Windows 10 with WSL. In the WSL bash terminal, when I run code ~/.bashrc it opens visual studio code to a blank file. Revealing the file in explorer shows that the path of this file is C:\home\[user], which is the Windows user directory, not the WSL/Ubuntu user directory.

When I run nano ~/.bashrc or vim ~/.bashrc, the default .bashrc file opens in nano/vim which I can edit. I was able to dig around and found that the path to this file is at C:\Users\[Windows user name]\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\[WSL user name]

Why do the commands code and nano recognize ~/ differently? And how can I make code point to the WSL/Ubuntu user directory?

User1996
  • 393
  • 1
  • 4
  • 9
  • Are `%HOME%` in the indows settings and `$HOME` is bash the same? – Walter A Apr 13 '19 at 22:11
  • In windows it points to the windows 10 user profile, while in BASH it points to the WSL/Ubuntu user profile. When I replace ~/ with $HOME in the original bash commands, the same thing occurs. – User1996 Apr 14 '19 at 12:39
  • Try to make them the same. Perhaps change the $HOME in the windows settings, or use `C:\home\[user]` as the homedir for WSL. Use the right slashes. Perhaps look at https://superuser.com/a/1134645 – Walter A Apr 14 '19 at 12:52
  • Ideally I would prefer not to have to modify these variables, for several reasons, one of which being that the WSL loads ~/.bashrc from the WSL home directory on startup. My question is trying to figure out why the Code command is defaulting to the windows home variable instead of the WSL home variable. – User1996 Apr 14 '19 at 21:44
  • I think you have downloaded a `zip` file for Windows, not a `.deb` file for Ubuntu. Perhaps you can change the configuration pointing to a different HOME or start folder. – Walter A Apr 15 '19 at 08:14

1 Answers1

0

WSL is not a VM or Container, it's just a layer on top of Windows kernel. You can find more here

If you do in WSL terminal

which nano

you get: /bin/nano or /usr/bin/vim, for vim but for

which code

/mnt/c/Program Files/Microsoft VS Code/bin/code

What I did is How to add multiple terminal in VS Code?