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

Cannot connect to WSL instance #71

Open
relief-melone opened this issue Nov 28, 2023 · 4 comments
Open

Cannot connect to WSL instance #71

relief-melone opened this issue Nov 28, 2023 · 4 comments

Comments

@relief-melone
Copy link

relief-melone commented Nov 28, 2023

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 nix-community/NixOS-WSL#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
Copy link

krad246 commented Mar 19, 2024

Also struggling with this one too.

@starcraft66
Copy link
Member

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

@Prince213
Copy link

Try this (add to system configuration):

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

@cydparser
Copy link

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"; }
  ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants