Bug description
Currently Nix environment variables do not take effect for wsl --exec. This problem affects VSCode Remote WSL extension badly because by default it uses wsl --exec to start the code server, which requires nix-ld and NIX_LD environment variable to execute properly.
To Reproduce
Steps to reproduce the behavior:
- Install last NixOS-WSL release https://github.com/nix-community/NixOS-WSL/releases/tag/22.05-5c211b47
- Run
wsl --exec nix --version from PowerShell
<3>WSL (1769) ERROR: CreateProcessEntryCommon:570: execvpe nix failed 2
<3>WSL (1769) ERROR: CreateProcessEntryCommon:579: Create process not expected to return
Expected behavior
Show Nix version, which should be 2.8.1
Logs
PS C:\Users\atry> wsl --exec nix
<3>WSL (1769) ERROR: CreateProcessEntryCommon:570: execvpe nix failed 2
<3>WSL (1769) ERROR: CreateProcessEntryCommon:579: Create process not expected to return
PS C:\Users\atry> wsl --exec env
HOSTTYPE=x86_64
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/ImageMagick-7.1.0-Q16-HDRI:/mnt/c/Python311/Scripts/:/mnt/c/Python311/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/Program Files/Microsoft VS Code/bin:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/GitHub CLI/:/mnt/c/Program Files (x86)/sbt/bin:/mnt/c/ProgramData/nvm:/mnt/c/Program Files/nodejs:/mnt/c/tools/gsudo/Current:/mnt/c/Program Files (x86)/Nodist/bin:/mnt/c/Program Files/Java/jdk1.8.0_211/bin:/mnt/c/Program Files/OpenJDK/jdk-19.0.2/bin:/mnt/c/ProgramData/chocolatey/lib/mpv.install/tools:/mnt/c/Users/atry/AppData/Local/Microsoft/WindowsApps:/mnt/c/ProgramData/chocolatey/lib/psutils/tools/psutils-master/:/mnt/c/Users/atry/AppData/Roaming/Python/Scripts
TERM=xterm-256color
XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir
DISPLAY=:0
WAYLAND_DISPLAY=wayland-0
PULSE_SERVER=/mnt/wslg/PulseServer
WSL2_GUI_APPS_ENABLED=1
WSLENV=WT_SESSION::WT_PROFILE_ID
WT_SESSION=4d87b811-c89e-4982-a071-2f47852fd7eb
WT_PROFILE_ID={61c54bbd-c2c6-5271-96e7-009a87ff44bf}
WSL_INTEROP=/run/WSL/1799_interop
NAME=DESKTOP-SICQMTD
HOME=/root
USER=root
LOGNAME=root
SHELL=env
WSL_DISTRO_NAME=NixOS
Bug description
Currently Nix environment variables do not take effect for
wsl --exec. This problem affects VSCode Remote WSL extension badly because by default it useswsl --execto start the code server, which requiresnix-ldandNIX_LDenvironment variable to execute properly.To Reproduce
Steps to reproduce the behavior:
wsl --exec nix --versionfrom PowerShellExpected behavior
Show Nix version, which should be 2.8.1
Logs