Prevent VSCode opening as root from WSL

Viewed 108

When opening VSCode in a folder using code . using my current user, I notice that then it was started as root. The steps that I'm making are to validate this behaviour are:

  1. $ whoami
    >> franciscoserrano
  2. $ mkdir test-dir && ll
    >> drwxr-xr-x 2 franciscoserrano franciscoserrano 4.0K Jan 18 19:04 test-dir
  3. $ cd test-dir
  4. $ code .
  5. (right after this, inside VSCode's terminal) $ pwd && whoami
/home/franciscoserrano/projects/test-dir
root

Another weird thing is that the VSCode terminal seems to load the .zshrc of my user, this is still inside VSCode terminal:

  1. $ pwd
    >> /home/franciscoserrano/projects/test-dir
  2. $ whoami && cd
    >> root
  3. $ pwd
    >> /home/franciscoserrano

Is this intended? Why making $ cd changes to a directory that is not from the user that outputs $ whoami? How do I force VSCode to open as the same user as in WSL?

Another detail: when creating files inside the same folder, using the VSCode GUI, those are also created as root:
-rw-r--r-- 1 root root 0 Jan 18 19:18 hello.c

0 Answers
Related