microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.67k stars 289 forks source link

NixOS-WSL Issues with Remote WSL Extension #6674

Open hschaeidt opened 2 years ago

hschaeidt commented 2 years ago

There is a issue when starting VSCode from within a NixOS. The node path does not resolve on NixOS systems. A known Workaround is to replace the /home/nixos/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d/node binary with a symlink to a locally installed NodeJS:

[2022-05-02 10:07:32.226] Resolving wsl+NixOS, resolveAttempt: 1
[2022-05-02 10:07:32.318] Starting VS Code Server inside WSL (wsl2)
[2022-05-02 10:07:32.318] Extension version: 0.66.2
[2022-05-02 10:07:32.318] Windows build: 22000. Multi distro support: available. WSL path support: enabled
[2022-05-02 10:07:32.318] No shell environment set or found for current distro.
[2022-05-02 10:07:32.425] WSL daemon log file: 
[2022-05-02 10:07:32.426] Probing if server is already installed: C:\WINDOWS\System32\wsl.exe -d NixOS -e sh -c "[ -d ~/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-05-02 10:07:32.520] Unable to detect if server is already installed: Error: Command failed: C:\WINDOWS\System32\wsl.exe -d NixOS -e sh -c "[ -d ~/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d ] && printf found || ([ -f /etc/alpine-release ] && printf alpine-; uname -m)"
[2022-05-02 10:07:32.520] sh: line 1: uname: command not found
[2022-05-02 10:07:32.520] 
[2022-05-02 10:07:32.520] 
[2022-05-02 10:07:32.520] 桳›楬敮ㄠ›湵浡㩥挠浯慭摮渠瑯映畯摮
[2022-05-02 10:07:32.521] Launching C:\WINDOWS\System32\wsl.exe -d NixOS sh -c '"$VSCODE_WSL_EXT_LOCATION/scripts/wslServer.sh" ed2619e11b68bec43b788486230b0c2afeb4672d insider code-server-insiders .vscode-server-insiders --host=127.0.0.1 --port=0 --connection-token=1607784020-279903489 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all'
[2022-05-02 10:07:32.733] Setting up server environment: Looking for /home/nixos/.vscode-server-insiders/server-env-setup. Not found.
[2022-05-02 10:07:32.733] WSL version: 5.10.16.3-microsoft-standard-WSL2 NixOS
[2022-05-02 10:07:32.733] Updating VS Code Server to version ed2619e11b68bec43b788486230b0c2afeb4672d
[2022-05-02 10:07:32.733] Removing previous installation...
[2022-05-02 10:07:32.733] Installing VS Code Server for x64 (ed2619e11b68bec43b788486230b0c2afeb4672d)
[2022-05-02 10:07:32.733] Downloading:     
[2022-05-02 10:07:33.032]   0%  0%  0%  0%  0%  0%  0%  0%  0%  0%  1%  1%  1%  1%  1%  1%  1%  1%  1%  1%  1%  2%  2%  2%  2%  2%  2%  2%  2%  2%  2%  2%  3%  3%  3%  3%  3%  3%  3%  3%  3%  3%  3%  4%  4%  4%  4%  4%  4%  4%  4%  4%  4%  5%  5%  5%  5%  5%  5%  5%  5%  5%  5%  5%  6%  6%  6%  6%  6%  6%  6%  6%  6%  6%  6%  7%  7%  7%  7%  7%  7%  7%  7%  7%  7%  7%  8%  8%  8%  8%  8%  8%  8%  8%  8%  8%  9%  9%  9%  9%  9%  9%  9%  9%  9%  9%  9% 10% 10% 10% 10% 10% 10% 10% 10% 10% 10% 10% 11% 11% 11% 11% 11% 11% 11% 11% 11% 11% 11% 12% 12% 12% 12% 12% 12% 12% 12% 12% 12% 12% 13% 13% 13% 13% 13% 13% 13% 13% 13% 13% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 14% 15% 15% 15% 15% 15% 15% 15% 15% 15% 15% 15% 16% 16% 16% 16% 16% 16% 16% 16% 16% 16%
[2022-05-02 10:07:33.337]  16% 17% 17% 17% 17% 17% 17% 17% 17% 17% 17% 18% 18% 18% 18% 18% 18% 18% 18% 18% 18% 18% 19% 19% 19% 19% 19% 19% 19% 19% 19% 19% 19% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 20% 21% 21% 21% 21% 21% 21% 21% 21% 21% 21% 22% 22% 22% 22% 22% 22% 22% 22% 22% 22% 22% 23% 23% 23% 23% 23% 23% 23% 23% 23% 23% 23% 24% 24% 24% 24% 24% 24% 24% 24% 24% 24% 24% 25% 25% 25% 25% 25% 25% 25% 25% 25% 25% 25% 26% 26% 26% 26% 26% 26% 26% 26% 26% 26% 27% 27% 27% 27% 27% 27% 27% 27% 27% 27% 27% 28% 28% 28% 28% 28% 28% 28% 28% 28% 28% 28% 29% 29% 29% 29% 29% 29% 29% 29% 29% 29% 29% 30% 30% 30% 30% 30% 30% 30% 30% 30% 30% 31% 31% 31% 31% 31% 31% 31% 31% 31% 31% 31% 32% 32% 32% 32% 32% 32% 32% 32% 32% 32% 32% 33% 33% 33% 33% 33% 33% 33% 33% 33% 33% 33% 34% 34% 34% 34% 34% 34% 34% 34% 34% 34% 35% 35% 35% 35% 35% 35% 35% 35% 35% 35% 35% 36% 36% 36% 36% 36% 36% 36% 36% 36% 36% 36% 37% 37% 37% 37% 37% 37% 37% 37% 37% 37% 37% 38% 38% 38% 38% 38% 38% 38% 38% 38% 38% 38% 39% 39% 39% 39% 39% 39% 39% 39% 39% 39% 40% 40% 40% 40% 40% 40% 40% 40% 40% 40% 40% 41% 41% 41% 41% 41% 41% 41% 41% 41% 41% 41% 42% 42% 42% 42% 42% 42% 42% 42% 42% 42% 42% 43% 43% 43% 43% 43% 43% 43% 43% 43% 43% 44% 44% 44% 44% 44% 44% 44% 44% 44% 44% 44% 45% 45% 45% 45% 45% 45% 45% 45% 45% 45% 45% 46% 46% 46% 46% 46% 46% 46% 46% 46% 46% 46% 47% 47% 47% 47% 47% 47% 47% 47% 47% 47% 48% 48% 48% 48% 48% 48% 48% 48% 48% 48% 48% 49% 49% 49% 49% 49% 49% 49% 49% 49% 49% 49% 50% 50% 50% 50% 50% 50% 50% 50% 50% 50% 50% 51% 51% 51% 51% 51% 51% 51% 51% 51% 51% 51% 52% 52% 52% 52% 52% 52% 52% 52% 52% 52% 53% 53% 53% 53% 53% 53% 53% 53% 53% 53% 53% 54% 54% 54% 54% 54% 54% 54% 54% 54% 54% 54% 55% 55% 55% 55% 55% 55% 55% 55% 55% 55% 55% 56% 56% 56% 56% 56% 56% 56% 56% 56% 56% 57% 57% 57% 57% 57% 57% 57% 57% 57% 57% 57% 58% 58% 58% 58% 58% 58% 58% 58% 58% 58% 58% 59% 59% 59% 59% 59% 59% 59% 59% 59% 59% 59% 60% 60% 60% 60% 60% 60% 60% 60% 60% 60% 61% 61% 61% 61% 61% 61% 61% 61% 61% 61% 61% 62% 62% 62% 62% 62% 62% 62% 62% 62% 62% 62% 63% 63% 63% 63% 63% 63% 63% 63% 63% 63% 63% 64% 64% 64% 64% 64% 64% 64% 64% 64% 64% 64% 65% 65% 65% 65% 65% 65% 65% 65% 65% 65% 66% 66% 66% 66% 66% 66% 66% 66% 66% 66% 66% 67% 67% 67% 67% 67% 67% 67% 67% 67% 67% 67% 68% 68% 68% 68% 68% 68% 68% 68% 68% 68% 68% 69% 69% 69% 69% 69% 69% 69% 69% 69% 69% 70% 70% 70% 70% 70% 70% 70% 70% 70% 70% 70% 71% 71% 71% 71% 71% 71% 71% 71% 71% 71% 71% 72% 72% 72% 72% 72% 72% 72% 72% 72% 72% 72% 73% 73% 73% 73% 73% 73% 73% 73% 73% 73% 74% 74% 74% 74% 74% 74% 74% 74% 74% 74% 74% 75% 75% 75% 75% 75% 75% 75% 75% 75% 75% 75% 76% 76% 76% 76% 76% 76% 76% 76% 76% 76% 76% 77% 77% 77% 77% 77% 77% 77% 77% 77% 77% 77% 78% 78% 78% 78% 78% 78% 78% 78% 78% 78% 79% 79% 79% 79% 79% 79% 79% 79% 79% 79% 79% 80% 80% 80% 80% 80% 80% 80% 80% 80% 80% 80% 81% 81% 81% 81% 81% 81% 81% 81% 81% 81% 81% 82% 82% 82% 82% 82% 82% 82% 82% 82% 82% 83% 83% 83% 83% 83% 83% 83% 83% 83% 83% 83% 84% 84% 84% 84% 84% 84% 84% 84% 84% 84% 84% 85% 85% 85% 85% 85% 85% 85% 85% 85% 85% 85% 86% 86% 86% 86% 86% 86% 86% 86% 86% 86% 87% 87% 87% 87% 87% 87% 87% 87% 87% 87% 87% 88% 88% 88% 88% 88% 88% 88% 88% 88% 88% 88% 89% 89% 89% 89% 89% 89% 89% 89% 89% 89% 89% 90% 90% 90% 90% 90% 90% 90% 90% 90% 90% 90% 91% 91% 91% 91% 91% 91% 91% 91% 91% 91% 92% 92% 92% 92% 92% 92% 92% 92% 92% 92% 92% 93% 93% 93% 93% 93% 93% 93% 93% 93% 93% 93% 94% 94% 94% 94% 94% 94% 94% 94% 94% 94% 94% 95% 95% 95% 95% 95% 95% 95% 95% 95% 95% 96% 96% 96% 96% 96% 96% 96% 96% 96% 96% 96% 97% 97% 97% 97% 97% 97% 97% 97% 97% 97% 97% 98% 98% 98% 98% 98% 98% 98% 98% 98% 98% 98% 99% 99% 99% 99% 99% 99% 99% 99% 99% 99%100%100%
[2022-05-02 10:07:34.265] Unpacking:   0%
[2022-05-02 10:07:34.571]   1%  2%  3%  4%  5%  6%  7%  8%  9% 10%
[2022-05-02 10:07:34.885]  11% 12% 13% 14% 15% 16% 17% 18% 19% 20% 21% 22% 23% 24% 25% 26% 27% 28% 29% 30% 31% 32% 33% 34% 35% 36% 37% 38% 39% 40% 41% 42% 43% 44% 45% 46% 47% 48% 49% 50% 51% 52% 53% 54% 55% 56% 57% 58% 59% 60% 61% 62% 63% 64% 65% 66% 67% 68% 69% 70% 71% 72% 73% 74% 75% 76% 77% 78% 79% 80% 81% 82% 83% 84% 85% 86% 87% 88% 89%
[2022-05-02 10:07:34.942]  90% 91% 92% 93% 94% 95% 96% 97% 98% 99%100%
[2022-05-02 10:07:34.942] Unpacked 2370 files and folders to /home/nixos/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d.
[2022-05-02 10:07:34.942] WSL-shell-PID: 16953
[2022-05-02 10:07:34.942] Node executable: /home/nixos/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d/node
[2022-05-02 10:07:34.942] Starting server: /home/nixos/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d/bin/code-server-insiders --host=127.0.0.1 --port=0 --connection-token=1607784020-279903489 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --telemetry-level=all
[2022-05-02 10:07:34.942] /home/nixos/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d/bin/code-server-insiders: line 12: /home/nixos/.vscode-server-insiders/bin/ed2619e11b68bec43b788486230b0c2afeb4672d/node: No such file or directory
[2022-05-02 10:07:34.943] VS Code Server for WSL closed unexpectedly.
[2022-05-02 10:07:34.943] For help with startup problems, go to
[2022-05-02 10:07:34.943] https://code.visualstudio.com/docs/remote/troubleshooting#_wsl-tips
[2022-05-02 10:07:34.944] C:\WINDOWS\System32\wsl.exe -d NixOS -e kill 16953
[2022-05-02 10:07:35.054] WSL Daemon exited with code 0

Steps to Reproduce:

  1. Set up NixOS-WSL latest release: https://github.com/nix-community/NixOS-WSL
  2. Install Remote-Containers WSL Extension
  3. code . from inside the WSL home directory (/home/nixos is the default username)
hypevhs commented 1 year ago

The unexpected CJK characters there 桳›楬敮ㄠ›湵浡㩥挠浯慭摮渠瑯映畯摮 when encoded as UTF-16 and then decoded as UTF-8 yields the text sh: line 1: uname: command not found.

hypevhs commented 1 year ago

After messing around with wrapping /bin/sh to always be a login shell, without much success, I've determined that the best workaround currently is to install https://github.com/msteen/nixos-vscode-server on the WSL NixOS.

This is just a workaround. Ideally VSCode remote should use the locally-installed NodeJS if it passes a basic smoke test.