无法从终端打开 VS Code(使用“code .”)

问题描述 投票:0回答:1

环境信息:VMware 16.2.3、Ubuntu22、VScode -1.78.2

我可以在早上使用

code .
打开 VS Code,但现在不能这样做,我想知道为什么。

我尝试过:

  1. 更改目录的权限。

    yindec@yindec-virtual-machine:~/Downloads/eosworks/orchestrator/modules/alioth$ sudo chown -R yindec .
    [sudo] password for yindec: 
    yindec@yindec-virtual-machine:~/Downloads/eosworks/orchestrator/modules/alioth$ code .
    mkdir: cannot create directory ‘’: No such file or directory
    yindec@yindec-virtual-machine:~/Downloads/eosworks/orchestrator/modules/alioth$ 
    
  2. 将用户切换到root。

    yindec@yindec-virtual-machine:~/Downloads/eosworks/orchestrator/modules/alioth$ su - root
    Password: 
    root@yindec-virtual-machine:~# cd /home/yindec/Downloads/eosworks/orchestrator/modules/alioth/
    root@yindec-virtual-machine:/home/yindec/Downloads/eosworks/orchestrator/modules/alioth# code .
    mkdir: cannot create directory ‘’: No such file or directory
    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.
    

    我看到了另一个问题,但不推荐。

  3. 我用错误关键字“mkdir:无法创建目录”进行谷歌搜索,但几乎所有搜索结果都是关于

    mkdir

  4. 我可以通过快捷方式打开 VS Code。

linux ubuntu visual-studio-code
1个回答
0
投票

如果您从 Ubuntu Store 或 Snap 安装了 VS Code,就会发生这种情况。

首先将其从系统中完全删除

sudo apt purge code
rm -rf ~/.vscode
rm -rf ~/.config/Code

并前往官方网站

下载 .deb 包并安装

sudo dpkg -i code_1.89.1-1715060508_amd64.deb

关闭您的终端,然后再次打开一个新终端。

你就可以出发了

code .
© www.soinside.com 2019 - 2024. All rights reserved.