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:
$ whoami
>> franciscoserrano$ mkdir test-dir && ll
>> drwxr-xr-x 2 franciscoserrano franciscoserrano 4.0K Jan 18 19:04 test-dir$ cd test-dir$ code .- (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:
$ pwd
>> /home/franciscoserrano/projects/test-dir$ whoami && cd
>> root$ 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