安装后 Visual Studio Code 无法启动

安装后 Visual Studio Code 无法启动

>与 SNAP 版本无关<

按照此处的说明通过终端安装 Visual Studio Code:https://code.visualstudio.com/docs/setup/linux

我没有执行sudo dpkg -i <file>.deb和,sudo apt-get install -f而是直接添加存储库和密钥,然后更新和安装(sudo apt install code)。

当以正常方式启动它时(Super输入visual,回车以启动应用程序),会显示忙光标一段时间然后停止。什么也没发生。

当开始使用终端并输入时code,什么也没有发生。

$ code --verbose

[main 9:06:54 PM] Startup error: ,,Error: EACCES: permission denied, mkdir '/home/*myusername*/.config/Code/CachedData',Error: EACCES: permission denied, mkdir '/home/*myusername*/.config/Code/logs/20180723T210654'
[main 9:06:54 PM] Lifecycle#kill()

$ apt list --installed code

Listing... Done
code/stable,now 1.25.1-1531323788 amd64 [installed]
N: There are 39 additional versions. Please use the '-a' switch to see them.

$ apt policy code

code:
  Installed: 1.25.1-1531323788
  Candidate: 1.25.1-1531323788
  Version table:
 *** 1.25.1-1531323788 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
        100 /var/lib/dpkg/status
     1.25.0-1530796411 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.24.1-1528912196 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.24.0-1528306776 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.23.1-1525968403 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.23.0-1525361119 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.22.2-1523551015 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.22.1-1522974421 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.21.1-1521038896 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.21.0-1520420608 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.20.1-1518535978 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.20.0-1518023506 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.19.3-1516876437 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.19.2-1515599945 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.19.1-1513676564 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.19.0-1513245498 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.18.1-1510857349 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.18.0-1510145176 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.17.2-1508162334 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.17.1-1507645403 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.17.0-1507160143 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.16.1-1505406497 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.16.0-1504714880 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.15.1-1502903936 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.15.0-1502309460 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.14.2-1500506907 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.14.1-1499973263 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.14.0-1499719149 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.13.1-1497464373 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.13.0-1496940180 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.12.2-1494422229 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.12.1-1493934083 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.12.0-1493915672 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.11.2-1492070517 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.11.1-1491486998 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.11.0-1491426847 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.10.2-1488981323 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.10.1-1488415350 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.10.0-1488387854 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages
     1.9.1-1486597190 500
        500 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages

至于 .config 目录的权限:

$ ls -la ~/.config/Code

total 24
drwxr-xr-x  4 root   root   4096 jun 25 23:08 .
drwx------ 19 myusername myusername 4096 jun 29 18:59 ..
-rw-r--r--  1 root   root     18 jun 25 23:08 installSource
drwxr-xr-x  4 root   root   4096 jun 25 23:08 logs
-rw-r--r--  1 root   root     36 jun 25 23:08 machineid
drwxr-xr-x  2 root   root   4096 jun 25 23:08 User

我是新手。显然“sudo code”不是解决我的问题的安全方法,所以我该怎么办?

运行 Ubuntu 18.04

答案1

您必须更改权限!设置错误。如果您有新的安装并且你的机器上从来没有项目,尝试重新安装代码,通过删除所有代码制作的文件

sudo apt purge code

然后重新安装

sudo apt install code

如果您有项目,您可以尝试更改配置目录的访问权限:

sudo chown -R myusername:myusername ~/.config/Code

相关内容