Reputation: 1443
Is there any way to get vs code to work properly in linux? I can't run sudo code .
because that gives me an error saying it's not secure to do so, I can't do anything within the editor to force doing things, like staging a file in git, or reloading a newly installed extension. I've googled around, and it seems nobody else has posted about this, and it seems highly unlikely that I'm the first to raise issue about this. (Take it easy on me, I'm a relatively new linux user). I'm trying to figure this out on Ubuntu 18.04 if that's relevant at all. My version of vs code is 1.30.2
I guess my main question is what's the right way to get applications like vs code to be able to perform tasks that required doing things without fighting the OS about sudo and privileges?
Upvotes: 1
Views: 18063
Reputation: 11
You basically need to tell the OS that you are the owner of the files you create. Use sudo chown <user name> <projects directory>
However, if you already created some files before applying chown, don't forget to change their permission also sudo chown <user name> <projects directory>/<file name>
.
Upvotes: 0
Reputation: 1495
sudo
from terminalTo launch VSCode as root --which is highly discouraged-- you must specify an alternate user data directory as follows:
$ sudo code --user-data-dir /path/to/alternate/folder
VSCode will automatically generate the required folders in the selected directory and launch with root privileges.
The solution in this case is to manually change the permissions of the two directories /home/$USER/.config/Code/
and /home/$USER/.vscode/
. Perform these steps:
$ sudo chmod 755 /home/$USER/.config/Code
$ sudo chmod 755 /home/$USER/.vscode
If you really need to run several commands as root and you are annoyed by having to enter your password several times (when sudo has expired), just do sudo -i
and you'll become root.
If you want to run commands using pipes, use sudo sh -c "comand1 | command2"
.
You may also want to take a look at this Ask Ubuntu answer about running applications as root.
Upvotes: 0