Nixpkgs: systemctl --user is broken

Created on 23 May 2016  Â·  25Comments  Â·  Source: NixOS/nixpkgs

Issue description

I've just upgraded to the latest nixos-unstable, and now all systemctl commands fail when passed the --user option.

Steps to reproduce

reboot to get as clean a state as possible

$ systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1
$ echo $?
1

Technical details

$ nixos-version
16.09.git.cc41cb3M (Flounder)
$ nix-env --version
nix-env (Nix) 1.11.2
$ nix-instantiate --eval '' -A lib.nixpkgsVersion
"16.09.git.cc41cb3M"

bug nixos

Most helpful comment

Same problem here, setting XDG_RUNTIME_DIR solves the problem:

$ systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1

but the following works:

$ XDG_RUNTIME_DIR="/run/user/$UID" systemctl --user

All 25 comments

works for me

$ nixos-version
16.09.git.13f67b9 (Flounder)
$ nix-env --version
nix-env (Nix) 1.11.2
$ nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion
"16.09.git.13f67b9"

where 13f67b9 is a private modification over cc41cb3 on something totally unrelated (unison downgrade).

Works here too:

[joelmo@jmdesk:~]$ nixos-version 
16.09pre83955.cc41cb3 (Flounder)

[joelmo@jmdesk:~]$ systemctl --user
UNIT                                LOAD   ACTIVE SUB       DES
sys-devices-pci0000:00-0000:00:17.0-ata1-host0-target0:0:0-0:0:
sys-devices-pci0000:00-0000:00:17.0-ata1-host0-target0:0:0-0:0:

having the same issue

~ nixos-version
16.09.git.125ffff (Flounder)
~ systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1

As root:

$ nixos-version 
16.03.1111.f231b2b (Emu)

$ systemctl --user
Failed to connect to bus: No such file or directory

As user it works.

$ nixos-version
16.03.1083.d745044 (Emu)
$ systemctl --user
UNIT                                                  LOAD   ACTIVE SUB     DESCRIPTION
...

Works for me:

~ > systemctl --user --no-pager
UNIT                           LOAD   ACTIVE SUB     DESCRIPTION
~ > nixos-version
16.09pre85931.125ffff (Flounder)
~ > nix-env --version 
nix-env (Nix) 1.11.2

Can we close this?

@siddhanathan the problem persists for me unfortunately.

~ systemctl --user --no-pager          
Failed to list units: Process org.freedesktop.systemd1 exited with status 1
~ nixos-version
16.09.git.125ffff (Flounder)
~ nix-env --version
nix-env (Nix) 1.11.2
~ date
Sat Jul 30 11:26:43 CEST 2016

The thing is, the issue is somewhat flakey and sometimes i even have it seen disappear. i do not know how to triage this. maybe it is due to low disk space. i will update the comment once i cleaned my root disk.

Update: no change with an emptier disk.

as root running:

~ systemctl --user
Failed to connect to bus: No such file or directory

but this may be related to an env virable not being set correctly.

Still happens on…

% nixos-version
16.09beta335.7617e7e (Flounder)
% systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1
% export | grep ^XDG
XDG_CONFIG_DIRS=/home/m/.nix-profile/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg
XDG_DATA_DIRS=/home/m/.nix-profile/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/m
XDG_SEAT=seat0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
XDG_SESSION_DESKTOP='none + i3'
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SESSION_TYPE=x11
XDG_VTNR=7
%

Please note, that XDG_RUNTIME_DIR is not exported, and it should be.

Same problem here, setting XDG_RUNTIME_DIR solves the problem:

$ systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1

but the following works:

$ XDG_RUNTIME_DIR="/run/user/$UID" systemctl --user

This should be set by pam_systemd on login. What is your session manager? @makefu, @michalrus
And what is the content of the corresponding pam configuration in /etc/pam.d/<name>

What is your session manager?

Using slim here.

cat --squeeze-blank /etc/pam.d/slim
# Account management.
account sufficient pam_unix.so

# Authentication management.

auth sufficient pam_unix.so nullok likeauth try_first_pass

auth required pam_deny.so

# Password management.
password requisite pam_unix.so nullok sha512

# Session management.
session required pam_env.so envfile=/nix/store/p6hd08lri1yi72jllc35lsdci1a0zdi0-pam-environment

session required pam_unix.so
session required pam_loginuid.so

session optional /nix/store/gslg75qdm4q88rpq1cfpgzhclcx1jipv-systemd-231/lib/security/pam_systemd.so

@Mic92, and I’m using LightDM (+ i3).

But this happens… only sometimes.

using slim + awesomewm issue also occurs _sometimes_, setting XDG_RUNTIME_DIR indeed fixes the issue.
The /etc/pam.d/slim of @ericsagnes is equal to mine (except for store paths)

Hey, I’ve got some new insight (perhaps).

Everytime when this happens (still does sometimes), running just systemctl highlights:

â—Ź [email protected]                                      loaded failed     failed
        User Manager for UID 31337

All other services are running correctly.

What is the status of this service, when it happens? systemctl status [email protected]

I’ll try to catch this situation again and then paste the status.

The latest nixos-unstable update fixed it for me.

Hmmm, I bumped into this today. My nixos-version: 18.09pre150708.083220867c7 (Jellyfish)

$ systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1

$ export XDG_RUNTIME_DIR=/run/user/$(id -u)

$ systemctl --user
UNIT                                 LOAD   ACTIVE SUB       DESCRIPTION                                            
sys-devices-virtual-net-wg0.device   loaded active plugged   /sys/devices/virtual/net/wg0                           
sys-devices-virtual-net-wg1.device   loaded active plugged   /sys/devices/virtual/net/wg1                           
sys-subsystem-net-devices-wg0.device loaded active plugged   /sys/subsystem/net/devices/wg0                         
sys-subsystem-net-devices-wg1.device loaded active plugged   /sys/subsystem/net/devices/wg1                         
-.mount                              loaded active mounted   Root Mount                                             
boot.mount                           loaded active mounted   /boot                                                  
dev-hugepages.mount                  loaded active mounted   /dev/hugepages                                         
dev-mqueue.mount                     loaded active mounted   /dev/mqueue                                            
flims.mount                          loaded active mounted   /flims                                                 
mnt-kktdr.backup.mount               loaded active mounted   /mnt/kktdr.backup                                      
mnt-kktdr.extend.mount               loaded active mounted   /mnt/kktdr.extend                                      
nix-store.mount                      loaded active mounted   /nix/store                                             
run-keys.mount                       loaded active mounted   /run/keys                                              
run-user-1000.mount                  loaded active mounted   /run/user/1000                                         
run-wrappers.mount                   loaded active mounted   /run/wrappers                                          
sys-kernel-debug.mount               loaded active mounted   /sys/kernel/debug                                      
tmp.mount                            loaded active mounted   /tmp                                                   
init.scope                           loaded active running   System and Service Manager                             
syncthing.service                    loaded active running   Syncthing - Open Source Continuous File Synchronization
-.slice                              loaded active active    Root Slice                                             
gpg-agent-ssh.socket                 loaded active listening GnuPG cryptographic agent (ssh-agent emulation)        
gpg-agent.socket                     loaded active listening GnuPG cryptographic agent and passphrase cache         
pulseaudio.socket                    loaded active listening Sound System                                           
basic.target                         loaded active active    Basic System                                           
default.target                       loaded active active    Default                                                
paths.target                         loaded active active    Paths                                                  
sockets.target                       loaded active active    Sockets                                                
timers.target                        loaded active active    Timers                                                 

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

28 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

I ran into this issue by accidentally removing all my permissions on my root drive (/), and then restoring them.

Setting XDG_RUNTIME_DIR does not seem to make a difference.

export XDG_RUNTIME_DIR=/run/user/$(id -u); systemctl --user
Failed to list units: Process org.freedesktop.systemd1 exited with status 1

@globin why has this issue been closed?

@chrissound what is your / filesystem? How did you restore them? systemd's journalctl, for example, requires facls set up.

@chrissound The permissions of /run should be fixed after reboot.

filesystem is ext4, permissions were restored with getfacl and setfacl.

Working fine after a reboot though.

I kept randomly running into this error:

systemctl status [email protected]
â—Ź [email protected] - User Manager for UID 1000
   Loaded: loaded (/nix/store/kinpd6wss80pf2d04jnvvmw25lzkrlbq-systemd-239/example/systemd/system/[email protected]; static; vendor preset: enabled)
  Drop-In: /nix/store/4q9hrmcg2l83cvypzdi2mrbh69zm9nss-system-units/[email protected]
           └─overrides.conf
   Active: failed (Result: protocol) since Mon 2019-01-21 09:21:36 GMT; 1h 17min ago
  Process: 1243 ExecStart=/nix/store/kinpd6wss80pf2d04jnvvmw25lzkrlbq-systemd-239/lib/systemd/systemd --user (code=exited, status=1/FAILURE)
 Main PID: 1243 (code=exited, status=1/FAILURE)

Jan 21 09:21:36 nixos systemd[1]: Starting User Manager for UID 1000...
Jan 21 09:21:36 nixos systemd[1243]: pam_unix(systemd-user:session): session opened for user chris by (uid=0)
Jan 21 09:21:36 nixos systemd[1243]: Failed to fully start up daemon: Permission denied
Jan 21 09:21:36 nixos systemd[1]: [email protected]: Failed with result 'protocol'.
Jan 21 09:21:36 nixos systemd[1]: Failed to start User Manager for UID 1000.

journalctl -u [email protected]:

Jan 21 09:21:36 nixos systemd[1]: Starting User Manager for UID 1000...
Jan 21 09:21:36 nixos systemd[1243]: pam_unix(systemd-user:session): session opened for user chris by (uid=0)
Jan 21 09:21:36 nixos systemd[1243]: Failed to fully start up daemon: Permission denied
Jan 21 09:21:36 nixos systemd[1]: [email protected]: Failed with result 'protocol'.
Jan 21 09:21:36 nixos systemd[1]: Failed to start User Manager for UID 1000.

When it does happen, just restarting the unit seems to work:
```
systemctl restart [email protected]
````

I get this state consistently when setting systemd.unified_cgroup_hierarchy=1 on the kernel command line.

Was this page helpful?
0 / 5 - 0 ratings