当前位置: 首页>后端>正文

You are trying to start Visual Studio Code as a super user which isn't recommended. If this was i...

在centos7 中通过wget 安装vscode(tar.gz格式)后,执行/bin/code出现提示

You are trying to start Visual Studio Code as a super user which isn't recommended. If this was intended, please add the argument --no-sandbox and specify an alternate user data directory using the --user-data-dir argument.
您正试图以超级用户身份启动Visual Studio代码,这是不推荐的。如果是这样,请添加参数“--no sandbox”,并使用“--user data dir”参数指定备用用户数据目录。

解决方法:
方法一:修改 ~/.bashrc

vi ~/.bashrc

添加一行

alias code='/usr/share/code/code . --no-sandbox --unity-launch'
source ~/.bashrc

此方法无效。
方法二:修改权限
...
此方法无效。

方法三:普通用户直接打开-成功
1.依照官网提供在方式安装

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
yum check-update
sudo yum install code

2.查看安装位置

whereis code
#code: /usr/bin/code /usr/share/code

3.新开终端以普通用户成功打开

/usr/bin/code
You are trying to start Visual Studio Code as a super user which isn't recommended. If this was i...,第1张

4.创建桌面快捷方式

vim /home/$yourname/桌面

填入

[Desktop Entry]
Name=Visual Studio Code
Comment=Multi-platform code editor for Linux
Exec=/usr/bin/code
Icon=/usr/share/code/resources/app/resources/linux/code.png
Type=Application
StartupNotify=true
Categories=TextEditor;Development;Utility;
MimeType=text/plain;

保存退出。

参考:https://code.visualstudio.com/docs/setup/linux


https://www.xamrdz.com/backend/36f1937984.html

相关文章: