microsoft / microsoft/vscode-remote-release

WSL (version 0.77.x) remote.WSL2.connectionMethod required

Open
#8,305 11 comments 21 reactions 1 assignee View on GitHub

@aeschli is already working on this.

Since Apr 5, 2023.

feature-request wsl
Dominant language
Dockerfile
Stars
4.2k
Forks
470
Avg merge
1d 1h
Merged PRs (30d)
1

Description

I cannot use WSL with VSCode since upgrading to vscode version 1.77, wsl extension 0.77.0.
I believe the problem is due to the removal of remote.WSL2.connectionMethod option.

I use NixOS as my linux host and need to set some specific environment variables for the node binaries vscode installs to work.
Specifically the node binary has hardcoded paths to the libraries (glibc and others) it uses, which are in a non standard place on NixOS. This can be worked around by setting some environment variables for the link loader to point it to the correct locations.

I have previously done (and still do) this via the server-env-setup script that is run during remote start. However this script is not run when starting the proxy wslExeProxy, which uses node on the linux host, which then fails to start, and so the remote connection fails.

The server-env-setup script looks like this

export NIX_LD=/nix/store/4hvajcn5v1r4gi3w14b951iv1p3g91wv-ld.so
export NIX_LD_LIBRARY_PATH=/nix/store/wvm2hvqdbbsp1f11463mrw8nyv678ipm-gcc-12.2.0-lib/lib:/nix/store/wvm2hvqdbbsp1f11463mrw8nyv678ipm-gcc-12.2.0-lib/lib

however those paths are liable to change so it would not be possible/sustainable to set them outside of the linux host.

  • VSCode Version: 1.77.0

  • Local OS Version: Windows_NT x64 10.0.19044

  • Remote OS Version: NixOS 22.11

  • Remote Extension/Connection Type: WSL (v2)

  • Logs:
    I think these are the relevant parts of the log, I can supply a full log if required.

[2023-03-31 14:37:33.813] Setting up server environment: Looking for /home/mike/.vscode-server/server-env-setup. Found, executing...
...
[2023-03-31 14:37:33.813] Node executable: /home/mike/.vscode-server/bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/node
[2023-03-31 14:37:33.813] Starting server: /home/mike/.vscode-server/bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/bin/code-server --host=127.0.0.1 --port=0 --connection-token=3596727786-3100391718-133394130-1811050027 --use-host-proxy --without-browser-env-var --disable-websocket-compression --accept-server-license-terms --log=trace --telemetry-level=all
[2023-03-31 14:37:33.813] *
[2023-03-31 14:37:33.813] * Visual Studio Code Server
[2023-03-31 14:37:33.813] *
[2023-03-31 14:37:33.813] * By using the software, you agree to
[2023-03-31 14:37:33.813] * the Visual Studio Code Server License Terms (https://aka.ms/vscode-server-license) and
[2023-03-31 14:37:33.813] * the Microsoft Privacy Statement (https://privacy.microsoft.com/en-US/privacystatement).
[2023-03-31 14:37:33.813] *
[2023-03-31 14:37:33.813] Server bound to 127.0.0.1:44347 (IPv4)
[2023-03-31 14:37:33.813] Extension host agent listening on 44347
...
[2023-03-31 14:37:33.829] Started local proxy server on 61810.
[2023-03-31 14:37:33.829] WSL resolver response: 127.0.0.1:61810
[2023-03-31 14:37:33.829] To debug connection issues, open a local browser on http://127.0.0.1:61810/version
[2023-03-31 14:37:33.829] No extension host environment set
[2023-03-31 14:37:33.845] Using executable (0) to forward requests from local 61810 to remote 44347
[2023-03-31 14:37:33.846] Exec 0: C:\WINDOWS\System32\wsl.exe -d NixOS -e /home/mike/.vscode-server/bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/node -e  const net = require('net'); process.stdin.pause(); const client = net.createConnection({ host: '127.0.0.1', port: 44347 }, () => { client.pipe(process.stdout); process.stdin.pipe(client); }); client.on('close', function (hadError) { console.error(hadError ? 'Remote close with error' : 'Remote close'); process.exit(hadError ? 1 : 0); }); client.on('error', function (err) { process.stderr.write(err && (err.stack || err.message) || String(err)); });
[2023-03-31 14:37:33.988] Exec (0): Local close
[2023-03-31 14:37:33.988] Terminating exec 0
[2023-03-31 14:37:34.020] Resolving wsl+NixOS, resolveAttempt: 2
[2023-03-31 14:37:34.020] Returning resolved promise.
[2023-03-31 14:37:34.020] Exec (0) has terminated (local socket closed) with code null and signal SIGKILL.
...

Steps to Reproduce:

  1. Use NixOS on WSL2 😁
  2. Try to use vscode

It is possible to replicate this behaviour outside of vscode:

[mike@nixos:~]$ cd .vscode-server/

[mike@nixos:~/.vscode-server]$ ls
bin  data  extensions  server-env-setup

[mike@nixos:~/.vscode-server]$ cat server-env-setup
export NIX_LD=/nix/store/4hvajcn5v1r4gi3w14b951iv1p3g91wv-ld.so
export NIX_LD_LIBRARY_PATH=/nix/store/wvm2hvqdbbsp1f11463mrw8nyv678ipm-gcc-12.2.0-lib/lib:/nix/store/wvm2hvqdbbsp1f11463mrw8nyv678ipm-gcc-12.2.0-lib/lib

[mike@nixos:~/.vscode-server]$ bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/node
cannot execute bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/node: NIX_LD or NIX_LD_x86_64-linux is not set

[mike@nixos:~/.vscode-server]$ source server-env-setup

[mike@nixos:~/.vscode-server]$ bin/7f329fe6c66b0f86ae1574c2911b681ad5a45d63/node
Welcome to Node.js v16.14.2.
Type ".help" for more information.
>

[mike@nixos:~/.vscode-server]$

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.