linux上的VS Code,各种权限错误 [英] VS Code on linux, various permissions errors

查看:40
本文介绍了linux上的VS Code,各种权限错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以让 vs 代码在 linux 中正常工作?我无法运行 sudo code . 因为这给了我一个错误,说这样做不安全,我不能在编辑器中做任何事情来强制做事,比如在 git 中暂存文件,或重新加载新安装的扩展.我已经用谷歌搜索了,似乎没有其他人发布过这个,而且我不太可能是第一个提出这个问题的人.(放轻松,我是一个相对较新的 linux 用户).如果这完全相关,我正在尝试在 Ubuntu 18.04 上解决这个问题.我的vs code版本是1.30.2

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

我想我的主要问题是让像 vs 代码这样的应用程序能够执行需要做的事情而不与操作系统有关 sudo 和特权的任务的正确方法是什么?

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?

推荐答案

从终端通过 sudo 启动

要以 root 身份启动 VSCode --这是非常不鼓励的--您必须指定备用用户数据目录,如下所示:

Launch via sudo from terminal

To 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 会在所选目录中自动生成所需的文件夹,并以 root 权限启动.

VSCode will automatically generate the required folders in the selected directory and launch with root privileges.

这种情况的解决办法是手动更改/home/$USER/.config/Code//home/$USER/.vscode/<这两个目录的权限/代码>.执行以下步骤:

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


回答您的其他问题:

如果您确实需要以 root 身份运行多个命令,并且对多次输入密码感到恼火(当 sudo 已过期时),只需执行 sudo -i 即可成为 root.


To answer your other question:

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.

如果您想使用管道运行命令,请使用 sudo sh -c "comand1 |command2".

If you want to run commands using pipes, use sudo sh -c "comand1 | command2".

您可能还想查看关于以 root 身份运行应用程序的这个 Ask Ubuntu 答案.

You may also want to take a look at this Ask Ubuntu answer about running applications as root.

这篇关于linux上的VS Code,各种权限错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆