I recently installed Visual Studio Code editor. I downloaded the 32bit .deb package. Installed and run normally, but when i tried to save a file in my project folder, it returns permission denied. So, i re-run code with
sudo code .
and it returns
It is recommended to start vscode as a normal user.
To run as root, you must specify an alternate user data directory with the --user-data-dir argument.
I looked for how to specify an alternate user data directory with the --user-data-dir
argument but I didn't find much.
So, how do I run Visual Studio Code as root in Ubuntu 16.04?
edit: I would prefer a solution that avoids changing directory permissions.
edit2: project directory: /var/www/project
(I'm using Apache with vhost)
Best Answer
It is very dangerous to run VScode as root (as it is any other application) however, should you absolutely need to:
You must specify the user data directory to use when running vs code:
Then from the window you can open your project folder
Again: This is not recommended. Have fun.
Update May 2018
For everyone asking why this isn't recommended, you clearly don't understand why
sudo
even exists. From this AskUbuntu Question:I'm not saying that you should never use VSCode as root(though its pretty easy to avoid doing) I'm saying you should be careful when you want to do so and know the risks.
The absolute best thing to do to is make a copy of a restricted file, edit it, and copy it back when you're absolutely sure it's finished.
Also for editing files to which your user does not have permissions, I would now recommend Talha Junaid's answer which asks for permissions every single time you want to save a file. The prompt for root access did not exist when I wrote this answer.