简体   繁体   English

从 Ubuntu WSL2 运行 VSCode 不工作

[英]Running VSCode from Ubuntu WSL2 not working

I am trying to run VSCode in my Ubuntu WSL2.我正在尝试在我的 Ubuntu WSL2 中运行 VSCode。

When I run code.当我运行code. , zsh is unable to find VSCode. , zsh 无法找到 VSCode。 I have installed Remote - WSL plugin in VSCode, and I am able to open my Ubuntu Instance from Windows. I want to achieve it from Ubuntu terminal as well.我已经在 VSCode 中安装了Remote - WSL插件,我可以从 Windows 打开我的 Ubuntu 实例。我也想从 Ubuntu 终端实现它。

ayman@DESKTOP  ~  code .
zsh: command not found: code

I have tried wsl --shutdown and then reinstalling Remote-WSL plugin, but it still does not work.我试过wsl --shutdown然后重新安装 Remote-WSL 插件,但它仍然不起作用。

Is there a zsh configuration required for running VSCode from terminal?从终端运行 VSCode 是否需要zsh配置? If so, what are the configurations required?如果是这样,需要什么配置?

If VSCode is in your Windows path, it should be in your WSL path as well.如果 VSCode 在您的 Windows 路径中,它也应该在您的 WSL 路径中。 Things to check:要检查的事情:

  • Is VSCode in your Windows path? VSCode 在你的 Windows 路径中吗? If not, add it there first.如果没有,请先将其添加到那里。

  • Windows path propagation to WSL is enabled by default, but double-check that. Windows 默认启用到 WSL 的路径传播,但请仔细检查。 Check to see if there's a line there in the [interop] section named appendWindowsPath .检查[interop]部分中是否有一行名为appendWindowsPath If it is set to false , change it to true or just delete the line altogether.如果它设置为false ,将其更改为true或完全删除该行。

  • Perhaps your startup scripts (eg ~/.zshrc ) are modifying the path (or setting a new one entirely)?也许您的启动脚本(例如~/.zshrc )正在修改路径(或完全设置一个新路径)? If so, append to the path in your startup scripts rather than replacing it.如果是这样,请将 append 添加到启动脚本中的路径,而不是替换它。

  • Any zsh extensions that could be modifying the path?任何可能修改路径的 zsh 扩展?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WSL2 (Ubuntu) 中的 Vscode:无法更新扩展,终端/外壳不工作 - Vscode in WSL2 (Ubuntu): Cant update extensions, terminal / shell not working 如何在 WSL2 中运行的 vscode 中设置 bash - How to setup bash in vscode running in WSL2 dbg 无法使用 WSL2 处理 VScode - 无法解析不存在的文件“vscode-remote://wsl+ubuntu-20.04..” - dbg not working on VScode with WSL2 - Unable to resolve non-existing file 'vscode-remote://wsl+ubuntu-20.04..' Ubuntu 升级后 WSL2 VSCode 将无法加载 - 工作正常 1 年 - WSL2 VSCode Will Not Load After Ubuntu upgrade - Worked fine for 1 year VSCode NodeJs:调试器不在断点处停止(WSL2/Ubuntu18) - VSCode NodeJs: Debugger not stopping at breakpoint (WSL2/Ubuntu18) 使用 Windows VSCode 编辑 Ubuntu Crontab 的 WSL2 实例 - Editing WSL2 instance of Ubuntu Crontab using Windows VSCode “代码。” 尝试打开 VSCode 时不再在 WSL2 中工作 - "code ." no longer working in WSL2 when attempting to open VSCode 使用 VSCode 和 WSL2 开发 Flutter - Developing Flutter with VSCode and WSL2 在 WSL2 上的网络上从 VSCode 公开 .NET Core WebAPI - Expose .NET Core WebAPI from VSCode on Network on WSL2 从远程服务器打开 VSCode 到本地,如 WSL2 - Open VSCode from Remotly Server to Local like WSL2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM