VSCode | 因意外错误无法打开编辑器

8

目标: 使Visual Studio Code中的Python项目正常使用Bash和Git终端。

每次启动时都会出现此错误。我无法打开code或使用终端。

Visual Studio Code screen

错误信息:

The editor cannot be opened due to an unexpected error: No file system provider found for resource 'vscode-remote://wsl%2Bubuntu/...'

更新: 卸载了WSL。我不再拥有下面旧的终端输出。

终端:

[2022-06-13 15:53:18.277] Resolving wsl+ubuntu, resolveAttempt: 1
[2022-06-13 15:53:18.361] Starting VS Code Server inside WSL (wsl1)
[2022-06-13 15:53:18.361] Extension version: 0.66.3
[2022-06-13 15:53:18.361] Windows build: 19044. Multi distro support: available. WSL path support: enabled
[2022-06-13 15:53:18.361] No shell environment set or found for current distro.
[2022-06-13 15:53:18.546] WSL daemon log file: 
[2022-06-13 15:53:18.548] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d Ubuntu -e sh -c "[ -d ~/.vscode-server/bin/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-06-13 15:53:19.023] Probing result: x86_64
[2022-06-13 15:53:19.024] No server install found in WSL, needs linux-x64
[2022-06-13 15:53:19.024] Downloading server on client side to C:\Users\dabell\AppData\Local\Temp\vscode-remote-wsl\c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5\vscode-server-stable-linux-x64.tar.gz.
[2022-06-13 15:53:19.024] https://update.code.visualstudio.com/commit:c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5/server-linux-x64/stable
[2022-06-13 15:53:26.719] Unable to download server on client side: Error: Request downloadRequest failed with message: getaddrinfo ENOTFOUND update.code.visualstudio.com. Will try to download on WSL side.
[2022-06-13 15:53:26.721] Launching C:\WINDOWS\System32\wsl.exe -d Ubuntu sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 stable code-server .vscode-server --host=127.0.0.1 --port=0 --connection-token=1433349295-3472956524-2784734323-674824766 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2022-06-13 15:53:27.103] Setting up server environment: Looking for /home/danielbellhv/.vscode-server/server-env-setup. Not found.
[2022-06-13 15:53:27.104] WSL version: 4.4.0-19041-Microsoft Ubuntu
[2022-06-13 15:53:27.104] Updating VS Code Server to version c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
[2022-06-13 15:53:27.104] Removing previous installation...
[2022-06-13 15:53:27.104] Installing VS Code Server for x64 (c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5)
[2022-06-13 15:53:27.104] Downloading:     
[2022-06-13 15:53:37.329] 100%
[2022-06-13 15:53:37.329] Failed
[2022-06-13 15:53:37.331] --2022-06-13 16:53:37--  https://update.code.visualstudio.com/commit:c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5/server-linux-x64/stable
[2022-06-13 15:53:37.331] Resolving update.code.visualstudio.com (update.code.visualstudio.com)... 
[2022-06-13 15:53:47.093] failed: Temporary failure in name resolution.
[2022-06-13 15:53:47.093] wget: unable to resolve host address ‘update.code.visualstudio.com’
[2022-06-13 15:53:47.093] ERROR: Failed to download https://update.code.visualstudio.com/commit:c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5/server-linux-x64/stable to /home/danielbellhv/.vscode-server/bin/c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5-1655135606.tar.gz
[2022-06-13 15:53:47.094] VS Code Server for WSL closed unexpectedly.
[2022-06-13 15:53:47.094] For help with startup problems, go to https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2022-06-13 15:53:47.116] WSL Daemon exited with code 0

这个问题已经困扰我将近两年了,我仍然不明白为什么会发生这种情况,也不明白为什么它不能被永久修复... - undefined
7个回答

9

可以通过重新启动 WSL 容器的网络来暂时解决此问题。

以管理员身份打开 Powershell 并运行以下命令:

Restart-Service LxssManager

建议将其保存到脚本中,例如 restart-WSL-network.ps1,并设置快捷方式以在再次出现此问题时运行它。


是的,这对我有用,谢谢!它也杀死了我的Docker桌面后端 :D - Gavin Burke

8

从Windows命令行运行wsl --shutdown,然后重新启动VSCode解决了我的问题。


1
这解决了我的问题。 - Farveaz
1
这对我来说很有效,而且似乎是大多数情况下最“正确”的解决方案。 - undefined

5
在wsl中删除主目录中的.vscode*文件夹可以解决此问题。

4

虽然我有点晚了,但今天我刚遇到这个问题。只是重启了Windows,现在它正常工作了!


1
在我的情况下,只有重新启动Windows才有帮助。此外,请尝试检查Pycharm是否可以访问此项目,因为这只是在Visual Studio Code中出现的错误。 - Alfred

0
我遇到了同样的问题,这是由于Ubuntu安装出现故障导致的;基本上,Ubuntu安装被强制中止,但仍然保留了一些配置,我可以通过wsl --list命令看到该发行版的列表。
我在Powershell中手动注销了该发行版,执行了以下命令:
wsl --unregister Ubuntu

之后,我还检查了wsl --list,以确保以下两点:
  1. 有问题的发行版已经不存在了

  2. 默认的发行版是正确的

然后一切都恢复正常了。

0

有些东西卡住了。无法重新启动wsl,所以重启了电脑,确保wsl正在运行,然后如果您使用docker,则打开docker和vscode就可以了。


-1

我只是从Windows商店卸载并重新安装了WSL 2。

你可以通过命令行操作,但我发现使用Windows商店更加方便和用户友好。


对于大多数企业来说,这并不是一个选择,因为笔记本电脑通常由域控制器禁用了Windows Store,以符合安全策略。 - CodeRed

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接