Visual Studio Code: Difference between revisions
imported>Dezren39 mNo edit summary |
imported>Atry No edit summary |
||
Line 241: | Line 241: | ||
== Remote WSL == | == Remote WSL == | ||
Similar to SSH hosts, both <code>nix-vscode-server</code> and <code>nix-ld</code> solution allows a VSCode Windows client to connect a [https://github.com/nix-community/NixOS-WSL NixOS-WSL] host. However, by default the VSCode Windows client uses <code>wsl.exe --exec</code> to start the code server, which bypasses NixOS environment variables required by <code>nix-ld</code>, resulting in failures. | Similar to SSH hosts, both <code>nix-vscode-server</code> and <code>nix-ld</code> solution allows a VSCode Windows client to connect a [https://github.com/nix-community/NixOS-WSL NixOS-WSL] host. However, by default the VSCode Windows client uses <code>wsl.exe --exec</code> to start the code server, which bypasses NixOS environment variables required by <code>nix-ld</code>, resulting in failures. | ||
As a workaround, search for the following text in all files under the directory <code>$HOME\.vscode\extension\</code> | |||
{{file|wslDaemon.js|js|<nowiki> | |||
[e,"-e",`const net = require('net'); | |||
</nowiki>}} | |||
Replace it with | |||
{{file|wslDaemon.js|js|<nowiki> | |||
["sh","-l","-c","exec \"$0\" \"$@\"",e,"-e",`const net = require('net'); | |||
</nowiki>}} | </nowiki>}} | ||
Then restart VS Code and your VS Code client should be able to connect to NixOS host | |||
See https://github.com/nix-community/NixOS-WSL/issues/222 for the discussion about <code>wsl --exec</code> issue on NixOS-WSL. | See https://github.com/nix-community/NixOS-WSL/issues/222 for the discussion about <code>wsl --exec</code> issue on NixOS-WSL. | ||
See https://github.com/microsoft/vscode-remote-release/issues/8305#issuecomment-1661396267 about the workaround. | |||
== Using nix-shell == | == Using nix-shell == |