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

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

Open mikeshepherd opened 1 year ago

mikeshepherd commented 1 year ago

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.

  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 commented 1 year ago

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

nzbr commented 1 year ago

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
Atry commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

SuperSandro2000 commented 1 year ago

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

acelinkio commented 1 year ago

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 commented 1 year ago

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

yasinuslu commented 10 months ago

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

perrylets commented 3 months ago

Has there been any progress with this issue?