nix-community / nixos-vscode-server

Visual Studio Code Server support in NixOS
MIT License
419 stars 76 forks source link

Cannot connect to WSL instance #71

Open relief-melone opened 1 year ago

relief-melone commented 1 year ago

I am unfortunately unable to connect to nixos from vs code. The setup works fine. the service gets created and I use systemctl to start it. However when starting code from within wsl or connecting from VSCode from my Host machine it errors with the following

Using shell environment from invoking shell: /tmp/vscode-distro-env.WSURtA [2023-11-28 08:45:01.857] Unable to detect if server is already installed: Error: Failed to probe if server is already installed: code: Failed to probe if server is already installed: code: 127, /nix/store/x88ivkf7rmrhd5x3cvyv5vh3zqqdnhsk-bash-interactive-5.2-p15/bin/sh: line 1: uname: command not found [2023-11-28 08:45:01.857] , install-found

Now what I found is that when connecting to the wsl instance in a shell first

# on host machine
wsl -d nixos

# inside wsl
uname -r
# outputs current kernel version 5.15.123.1-microsoft-standard-WSL2

everything works fine

However when running the same command directly from the host machine

wsl -d nixos -- uname -r

it will error out with uname not being found just like in the VSCode instance. This might also be related to this issue on NIXOS-WSL https://github.com/nix-community/NixOS-WSL/issues/222

I know wsl support is still a wip in this project but it seems like people have been able to make it work. It would be great if someone had the knowledge what I can do to connect.

krad246 commented 8 months ago

Also struggling with this one too.

starcraft66 commented 6 months ago

Having the same issue. Adding coreutils to environment.systemPackages did not help either.

Prince213 commented 5 months ago

Try this (add to system configuration):

{ lib, pkgs, ... }: {
  wsl.extraBin = [
    { src = lib.getExe' pkgs.coreutils "uname"; }
  ];
}
cydparser commented 5 months ago

Thanks @Prince213. Adding the following (and installing wget) worked for me:

  wsl.extraBin = [
    { src = lib.getExe' pkgs.coreutils "dirname"; }
    { src = lib.getExe' pkgs.coreutils "readlink"; }    
    { src = lib.getExe' pkgs.coreutils "uname"; }
  ];