Closed Cody119 closed 7 months ago
I did note that some of the earlier logs suggested that vscode was running shell commands using wsl -d NixOS -e sh "
".
Yes you are right and I'm supposing that the command is not executed as user nixos
.
Instead of adding wget
into nix profile, can you try adding it to system path by adding this to configuration.nix
and rebuild the OS?
environment.systemPackages = with pkgs; [
wget
];
Thansk for the reply!
Instead of adding wget into nix profile, can you try adding it to system path by adding this to configuration.nix and rebuild the OS?
Still wasn't able to access wget from wsl -d NixOS -e sh
after doing this.
After messing around a bit, I was able to modify NixOS-WSL to get wget
installed in the sh
enviroment with the following diff:
diff --git a/modules/systemd/native/default.nix b/modules/systemd/native/default.nix
index f641580..ae0afc6 100644
--- a/modules/systemd/native/default.nix
+++ b/modules/systemd/native/default.nix
@@ -7,7 +7,7 @@ with lib; {
nativeUtils = pkgs.callPackage ../../../utils { };
bashWrapper = pkgs.writeShellScriptBin "sh" ''
- export PATH="$PATH:${lib.makeBinPath [ pkgs.systemd pkgs.gnugrep ]}"
+ export PATH="$PATH:${lib.makeBinPath [ pkgs.systemd pkgs.gnugrep pkgs.wget ]}"
exec ${pkgs.bashInteractive}/bin/sh "$@"
'';
in
This seems to have fixed it, although obviosuly I had to modify NixOS-WSL which is a bit of a pain.
Do you think this is related to a recent update to the way vs code is installing the sever? Did it used to use the WSL default shell for each distor instead of directly using sh
? Just confused as to why this is suddenly an issue.
Do you think this is related to a recent update to the way vs code is installing the sever?
Could you give details about what has been changed with vscode?
I updated my environment and my vscode can download the server with any problem. (I updated vscode, WSL extension, and NixOS-WSL)
Strangely, the command you provided are not working for me as well:
>wsl -d NixOS -e sh "wget"
/nix/store/x88ivkf7rmrhd5x3cvyv5vh3zqqdnhsk-bash-interactive-5.2-p15/bin/sh: wget: No such file or directory
I think I figured out what's going on here.
The sh
used in the recent version (2311.5.3) of NixOS-WSL is kind of meh. It even doesn't have ls
command in its path:
>wsl -d NixOS sh -c ls
/nix/store/x88ivkf7rmrhd5x3cvyv5vh3zqqdnhsk-bash-interactive-5.2-p15/bin/sh: line 1: ls: command not found
However the script should work because I modified PATH
envvar so that the NixOS system packages (environment.systemPackages
) should be available in the sh
:
https://github.com/sonowz/vscode-remote-wsl-nixos/blob/b8f59ee7839d00a3123c84ebe682318c023377fe/server-env-setup#L8
Thus, when wget
is missing, you can put wget
in system packages (as I did) or systemd derivation (as you did above). Either should work.
Do you think this is related to a recent update to the way vs code is installing the sever?
In other words, I think it has nothing to do with the recent update and the cause is that wget
was not available in your system.
I'm closing this issue, and feel free to reopen it when something doesn't work :)
Hey thanks for following up. Sorry for disapearing, the whole thing completely fell out of my mind for a while haha.
Thus, when wget is missing, you can put wget in system packages (as I did) or systemd derivation (as you did above). Either should work.
I am pretty sure I tried putting it in system package with no luck, but if I get a chance ill give it another shoot. What your saying makes sense so im inclinded to believe I just made a mistake when doing it.
This might be realted to #6 but not 100% sure. Still a bit new to NixOS so forgive me if I missed anything obvious.
Installed wget as instructed but im getting an error when I try to connect saying that wget is not installed:
wget installation:
system info:
I was able to get everything working by running
code .
directly into the NixOS terminal as suggested by the vscode troubleshooting docs, but since that isn't mentioned anywhere in the readme I wanted to see if I was missing anything.I did note that some of the earlier logs suggested that vscode was running shell commands using
wsl -d NixOS -e sh "<command>"
. When I try to access wget through this method I get a "command not found" error. I assume using "sh" directly like this skips setting up PATH properly in Nix. Im not sure how vscode calls wget for the server install so this may be unrelated.p.s. other than this minor issue, script works great! Thanks for sharing!