docker - 在 Visual Studio Code 中使用 Docker 和 WSL 2 进行开发 - -sh: code: not found
问题描述
我按照https://docs.docker.com/docker-for-windows/wsl/上的教程进行操作。我已完成先决条件步骤:
- 安装 Windows 10 版本 2004 或更高版本。
- 在 Windows 上启用 WSL 2 功能。有关详细说明,请参阅 Microsoft 文档。
- 下载并安装 Linux 内核更新包。
并完成了第 1 步 -Open VSCode and install the Remote - WSL extension. This extension allows you to work with a remote server in the Linux distro and your IDE client still on Windows.
但是在第 2 步中,当我运行时code .
,它会引发错误-sh: code: not found
解决方案
您的路径缺少来自 linux shell 的 Visual Studio 代码路径尝试
$export PATH="$PATH:/mnt/c/Users/{username}/AppData/Local/Programs/Microsoft VS Code"
这只会暂时起作用。下次打开外壳时,您将不得不再次打开它。
使永久
$vi ~/.profile
添加行
export PATH="$PATH:/mnt/c/Users/{username}/AppData/Local/Programs/Microsoft VS Code"
到文件的末尾。然后重新启动你的shell,它应该很好去
推荐阅读
- javascript - 如何在 webpack 配置中包含和使用 DefinePlugin?
- php - How does laravel know the unread notifications i not see any difference in the notifications table?
- javascript - 如何减少div的前z-index?
- c - C程序中的奇怪行为,分配内存后变量损坏
- php - 使用 cURL 在 api 中拒绝承载授权
- moqui - 通过电子邮件向订阅用户发送 NotificationMessage
- php - PHP Curl 获取数据
- python - Matplotlib:绘制自定义图例
- sql - Sql查询根据不同的场景将值分配给具有来自其他行的空值的列
- regex - Powershell 在正则表达式匹配组的末尾添加 CR