我在 ubuntu linux 中使用带有此命令的 Visual Studio 代码
以 root 权限运行 VS Code(不推荐)
sudo code --user-data-dir="~/.vscode-root"
我总是在命令行中使用它,因为正常方式的 Visual Studio 代码不允许我保存我的代码更新。但今天
sudo code --user-data-dir="~/.vscode-root"
当我尝试在命令行中运行它时,此代码不再起作用,它不再打开 Visual Studio 代码。单击 vscode 图标正常运行,但它不允许我保存任何内容,它要求我以 sudo 重试,我这样做但它什么也不做,我无法以这种方式以 sudo 身份输入。
有关如何解决此问题的任何建议?
提前致谢
最佳答案
最佳方式(推荐):
就用这个:sudo code "your-directory" --user-data-dir='.' --no-sandbox
例如打开 /etc/nginx/nginx.conf
, 使用 :sudo code /etc/nginx/nginx.conf --user-data-dir='.' --no-sandbox
vscode will create files where you open terminal because of :
--user-data-dir='.'
另一种方式(不推荐):
使用
sudo chmod -R 777
But it will give the full access of your project directory to all users on the machine
您可以在项目目录上使用 chown 只为自己拥有它
cd /location
sudo chown your_username your_project_directory
示例:假设我有一个名为
project1
的目录在我的/var/opt
位置,我的用户名是 tom。cd /var/opt
sudo chown tom project1
关于ubuntu - 在 ubuntu linux 中以 root 权限运行 VS Code 不再起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67929938/