【问题标题】:Visual Studio Code is not working on WSL2Visual Studio Code 不适用于 WSL2
【发布时间】:2020-11-09 10:07:38
【问题描述】:

当我尝试在 WSL2 终端中打开 VS Code 时,如下所示:

code . 

我收到以下错误:

mkdir: cannot create directory {DIRECTORY} : Permission denied

使用 sudo 开始时:

sudo: code: command not found

我在 Windows 上的 PATH 中添加了 VS Code,并安装了 WSL-Remote

我正在努力:

  • Windows 10 专业版 10.0.19041
  • WSL 2
  • Ubuntu 20.04 LTS
  • VS 代码 1.47.1

【问题讨论】:

    标签: visual-studio-code windows-subsystem-for-linux


    【解决方案1】:

    查看配置文件(/etc/sudoers),需要修改secure_path以启用sudo命令运行VS代码。

    另外,最好把命令路径放到/etc/profile,这样每个用户都可以运行VS code。

    【讨论】:

    • 我们能不能把它作为可选文本而不是图片?
    • 这对我有用:secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/mnt/c/Programs/Microsoft VS Code/bin"
    猜你喜欢
    • 2016-07-14
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 2022-07-07
    • 2020-06-13
    • 2022-01-21
    • 2021-10-24
    • 2020-01-12
    相关资源
    最近更新 更多