WSL 不适用于 VS 代码。这里可能是什么问题?
WSL isn't working in VS code. What could be the problem here?
您好,我是使用 Linux 环境和 VS 代码的新手。
我已经使用 windows 终端访问 WSL2 并且运行良好。
我正在尝试设置开发环境,但 WSL 无法在 VS 代码中运行。
我该如何解决这里的问题?
它一直显示“WSL 的 VS 代码服务器意外关闭”。留言。
[2020-12-03 07:24:35.010] Resolving wsl+docker-desktop, resolveAttempt: 1
[2020-12-03 07:24:35.106] Starting VS Code Server inside WSL (docker-desktop)
[2020-12-03 07:24:35.106] Extension version: 0.51.4, Windows build: 19041. Multi distro support: available. WSL path support: enabled
[2020-12-03 07:24:35.107] No shell environment set or found for current distro.
[2020-12-03 07:24:35.317] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop -e sh -c "[ -d ~/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2020-12-03 07:24:37.900] Probing result: found
[2020-12-03 07:24:37.901] Server install found in WSL
[2020-12-03 07:24:37.901] Launching C:\WINDOWS\System32\wsl.exe -d docker-desktop sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" e5a624b788d92b8d34d1392e4c4d9789406efe8f stable .vscode-server 0 '}
[2020-12-03 07:24:38.017] Setting up server environment: Looking for /root/.vscode-server/server-env-setup. Not found.
[2020-12-03 07:24:38.017] WSL version: 4.19.128-microsoft-standard docker-desktop
[2020-12-03 07:24:38.017] WSL2-shell-PID: 11
[2020-12-03 07:24:38.017] Starting server: /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh --port=0 --use-host-proxy --enable-remote-auto-shutdown
[2020-12-03 07:24:38.018] /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh: line 12: /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/node: not found
[2020-12-03 07:24:38.018] VS Code Server for WSL closed unexpectedly.
[2020-12-03 07:24:38.018] For help with startup problems, go to
[2020-12-03 07:24:38.018] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2020-12-03 07:24:38.021] C:\WINDOWS\System32\wsl.exe -d docker-desktop -e kill 11
[2020-12-03 07:24:38.171] WSL Daemon exited with code 0
- 在 Vs 代码中
ctrl+schift+p
- 打开
Preferences: Open Settings (JSON)
- 添加
"terminal.integrated.shell.windows": "wsl.exe",
- 重新打开终端。
如果您需要打开特定的发行版,那么另外例如:
"terminal.integrated.shellArgs.windows": ["-d", "Ubuntu-20.04"],
- 重新打开终端。
我遇到了同样的问题,不过重启WSL2发行版就解决了。我正在使用 Ubuntu-20.04
,所以我使用以下命令重新启动。重启后,重新打开 VS Code,希望你的问题能得到解决。
wsl -t Ubuntu-20.04
在vscode终端:
which node
并将路径粘贴到 launch.json:
"runtimeExecutable": "<path>/node/v14.15.5/bin/node",
我的问题是通过打开 Ubuntu 终端并从那里启动 vscode 来解决的。 wsl 中缺少一个包,我无法通过编辑 vscode 中的任何配置文件来安装它。安装该软件包后,vscode 能够启动与 wsl
的远程连接
在vscode设置中,远程WSL设置>>扩展设置
Remote.WSL2:连接方法
select wsl2VMAddress
WSL2 版本 2 使用不同于 Windows10 主机 IP 的虚拟专用网络。它每次都会更改其 IP 地址,所以...如果 WSL2 中的 VS 代码 运行 可以获取更改,那么它可能会更好地工作。否则,我们必须在 WSL2 端禁用 IP 的自动生成。
Windows 在我的 BIOS 中禁用 虚拟化 更新。可以运行PowerShell中的wsl命令检查wsl环境是否正常
您好,我是使用 Linux 环境和 VS 代码的新手。 我已经使用 windows 终端访问 WSL2 并且运行良好。
我正在尝试设置开发环境,但 WSL 无法在 VS 代码中运行。 我该如何解决这里的问题? 它一直显示“WSL 的 VS 代码服务器意外关闭”。留言。
[2020-12-03 07:24:35.010] Resolving wsl+docker-desktop, resolveAttempt: 1
[2020-12-03 07:24:35.106] Starting VS Code Server inside WSL (docker-desktop)
[2020-12-03 07:24:35.106] Extension version: 0.51.4, Windows build: 19041. Multi distro support: available. WSL path support: enabled
[2020-12-03 07:24:35.107] No shell environment set or found for current distro.
[2020-12-03 07:24:35.317] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d docker-desktop -e sh -c "[ -d ~/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2020-12-03 07:24:37.900] Probing result: found
[2020-12-03 07:24:37.901] Server install found in WSL
[2020-12-03 07:24:37.901] Launching C:\WINDOWS\System32\wsl.exe -d docker-desktop sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" e5a624b788d92b8d34d1392e4c4d9789406efe8f stable .vscode-server 0 '}
[2020-12-03 07:24:38.017] Setting up server environment: Looking for /root/.vscode-server/server-env-setup. Not found.
[2020-12-03 07:24:38.017] WSL version: 4.19.128-microsoft-standard docker-desktop
[2020-12-03 07:24:38.017] WSL2-shell-PID: 11
[2020-12-03 07:24:38.017] Starting server: /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh --port=0 --use-host-proxy --enable-remote-auto-shutdown
[2020-12-03 07:24:38.018] /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/server.sh: line 12: /root/.vscode-server/bin/e5a624b788d92b8d34d1392e4c4d9789406efe8f/node: not found
[2020-12-03 07:24:38.018] VS Code Server for WSL closed unexpectedly.
[2020-12-03 07:24:38.018] For help with startup problems, go to
[2020-12-03 07:24:38.018] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2020-12-03 07:24:38.021] C:\WINDOWS\System32\wsl.exe -d docker-desktop -e kill 11
[2020-12-03 07:24:38.171] WSL Daemon exited with code 0
- 在 Vs 代码中
ctrl+schift+p
- 打开
Preferences: Open Settings (JSON)
- 添加
"terminal.integrated.shell.windows": "wsl.exe",
- 重新打开终端。
如果您需要打开特定的发行版,那么另外例如:
"terminal.integrated.shellArgs.windows": ["-d", "Ubuntu-20.04"],
- 重新打开终端。
我遇到了同样的问题,不过重启WSL2发行版就解决了。我正在使用 Ubuntu-20.04
,所以我使用以下命令重新启动。重启后,重新打开 VS Code,希望你的问题能得到解决。
wsl -t Ubuntu-20.04
在vscode终端:
which node
并将路径粘贴到 launch.json:
"runtimeExecutable": "<path>/node/v14.15.5/bin/node",
我的问题是通过打开 Ubuntu 终端并从那里启动 vscode 来解决的。 wsl 中缺少一个包,我无法通过编辑 vscode 中的任何配置文件来安装它。安装该软件包后,vscode 能够启动与 wsl
的远程连接在vscode设置中,远程WSL设置>>扩展设置 Remote.WSL2:连接方法 select wsl2VMAddress
WSL2 版本 2 使用不同于 Windows10 主机 IP 的虚拟专用网络。它每次都会更改其 IP 地址,所以...如果 WSL2 中的 VS 代码 运行 可以获取更改,那么它可能会更好地工作。否则,我们必须在 WSL2 端禁用 IP 的自动生成。
Windows 在我的 BIOS 中禁用 虚拟化 更新。可以运行PowerShell中的wsl命令检查wsl环境是否正常