Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mikeshepherd opened this issue Mar 31, 2023 · 9 comments
Open

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

mikeshepherd opened this issue Mar 31, 2023 · 9 comments
Assignees
Labels
feature-request Request for new features or functionality wsl Issue in vscode-remote WSL
Milestone

Comments

@mikeshepherd
Copy link

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]$
@purepani
Copy link

purepani commented Apr 1, 2023

This is also an issue I have run into. I am forced to downgrade the extension for now unfortunately.

@nzbr
Copy link

nzbr commented Apr 2, 2023

Thank you for the hint @purepani! At least I have an editor again (for now)
For anyone else stumbling upon this, the command is

code --install-extension ms-vscode-remote.remote-wsl@0.76.0

@aeschli aeschli self-assigned this Apr 5, 2023
@Atry
Copy link

Atry commented Apr 23, 2023

The required environment variables can be found from a login shell

wsl -e sh -l -c env # NIX_LD is available
wsl -e env # NIX_LD is not available

@Atry
Copy link

Atry commented Aug 2, 2023

Workaround:

Search for the following text in all files under the directory $HOME\.vscode\extensions\

.push("sh","-c"

Replace it with

.push("sh","-l","-c"

Restart VS Code

@Atry
Copy link

Atry commented Aug 2, 2023

@aeschli I wonder if you would like to apply the change as I described in the above comment?

@SuperSandro2000
Copy link

I am just trying to be annoying to get some attention to this issue.

@acelinkio
Copy link

Definitely would appreciate if more attention was given to this. I understand that this is a NixOS specific challenge and that the mainstream WSL distros work, but would love to see some additional support from the extension team.

@purepani
Copy link

purepani commented Nov 3, 2023

Same, I have to switch between Linux and windows a lot so it would be good if I could properly use this extension.

@yasinuslu
Copy link

I'm also having problems with NixOS-WSL. Would love to find a good solution

@aeschli aeschli added the feature-request Request for new features or functionality label Jan 9, 2024
@aeschli aeschli added this to the On Deck milestone Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality wsl Issue in vscode-remote WSL
Projects
None yet
Development

No branches or pull requests

8 participants