NixOS-WSL
NixOS-WSL copied to clipboard
Systemctl with user flag don't work
Bug description
Using any commands of systemctl with the --user flag like systemctl list-unit-files --user --state=enabled
with systemd native support activate gives the error: Failed to connect to bus: No such file or directory
To Reproduce
Steps to reproduce the behavior:
- Activate native systemd adding
wsl.nativeSystemd = true;
to /etc/nixos/configuration.nix - Run
systemctl list-unit-files --user --state=enabled
Expected behavior
The command execute without errors.
In the example command it should display all units.
Logs
Similar to #165 doing systemctl list-unit-files --user --state=enabled
with native systemd support turned off works perfectly:
UNIT FILE STATE PRESET
emacs.service enabled enabled
nixos-activation.service enabled enabled
dbus.socket enabled enabled
gpg-agent-ssh.socket enabled enabled
gpg-agent.socket enabled enabled
5 unit files listed.
While with native systemd support turned off errors:
Failed to connect to bus: No such file or directory
Are you using WSL2?
I am
This is a bug/missing feature in WSL. My Ubuntu distro with systemd enabled for example behaves exactly the same. syschdemd included a workaround that made this work, but Microsoft's systemd implementation (which we call native) does not have that
I'll leave this open, because I do in fact consider this a bug, but in WSL, not here. There might be possible workarounds, but I'd much rather see Microsoft fix it
This is a bug/missing feature in WSL. My Ubuntu distro with systemd enabled for example behaves exactly the same. syschdemd included a workaround that made this work, but Microsoft's systemd implementation (which we call native) does not have that
Alright I will make a issue in wsl repo and keep you/this issue updated
The issue isn't always present. Right now I do not have the issue, whereas some days ago I was encountering it.
It's worth noting though that services and stuff takes a bit of time to start up (at least for me, even nix-daemon), so by trying to reproduce the issue directly after the shell is available, you'll 100% encounter the issue. Check the startup is actually finished by using htop
or similar before attempting to reproduce, you should see a bunch of stuff starting.
Experiencing this, programs.ssh.startAgent wasn't working for me, using nativeSystemd = false; solves the issue, but really isn't ideal...
$ wsl --version WSL version: 2.2.4.0 Kernel version: 5.15.153.1-2 WSLg version: 1.0.61 MSRDC version: 1.2.5326 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26091.1-240325-1447.ge-release Windows version: 10.0.22631.4037
Is there an active issue for this on the WSL(g?) repo?
Issue for me as well with, e.g., ssh-agent
from home-manager. The user systemd unit is not enabled/working/ with native systemd enabled.
systemctl --user
# Failed to connect to bus: No such file or directory
WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.19045.4651