You are not logged in.

#1 2022-01-04 14:14:59

josemota
Member
Registered: 2010-10-24
Posts: 47

[SOLVED] [systemd] Cannot enable user-level services

I ran a regular system update in the last few days and I noticed that my user-level enabled services were not being booted.

$ cat ~/.config/systemd/user/emacs.service
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=forking
ExecStart=/usr/bin/emacs -l ~/.emacs.el --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure

[Install]
WantedBy=default.target%

I have noticed that enabling the service manually does not return a descriptive statement anymore, leading me to think it is not being correctly registered. However, the command returns 0 which reads inconsistently to me.

$ systemctl --user enable emacs
$ echo $?
0

If I only start the service, it does boot. This leads me to deduce that the service file is correct and leads me to confirm that either the `enable`command is buggy or I have misspelled something.

$ systemctl --user start emacs
$ echo $?
0

Last edited by josemota (2022-01-04 23:59:35)

Offline

#2 2022-01-04 14:25:22

jfernyhough
Member
Registered: 2012-09-26
Posts: 7

Re: [SOLVED] [systemd] Cannot enable user-level services

What does

systemctl --user status emacs

say? Are there other user services that you are finding the same with, and what is their status? What's the status of the `user@$UID.service` ?

(For reference, all of my user services have remained operational during the systemd=250 updates; I think the main/only change I made to the default was to enable linger for my user)

Offline

#3 2022-01-04 14:30:01

josemota
Member
Registered: 2010-10-24
Posts: 47

Re: [SOLVED] [systemd] Cannot enable user-level services

jfernyhough wrote:

What does systemctl --user status emacs say?

$ systemctl --user status emacs                                                                                                                                                                                                                                                                                           ~
● emacs.service - Emacs text editor
     Loaded: loaded (/home/jose/.config/systemd/user/emacs.service; linked; vendor preset: enabled)
     Active: active (running) since Tue 2022-01-04 11:43:08 WET; 2h 43min ago
       Docs: info:emacs
             man:emacs(1)
             https://gnu.org/software/emacs/
   Main PID: 52433 (emacs)
      Tasks: 4 (limit: 19075)
     Memory: 181.8M
        CPU: 7.175s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/emacs.service
             └─52433 /usr/bin/emacs -l ~/.emacs.el --daemon

jan 04 11:43:07 workstation-linux emacs[52433]: Loaded /home/jose/.config/emacs/config.el
jan 04 11:43:07 workstation-linux emacs[52433]: Turning on magit-auto-revert-mode...
jan 04 11:43:07 workstation-linux emacs[52433]: Turning on magit-auto-revert-mode...done
jan 04 11:43:07 workstation-linux emacs[52433]: Starting Emacs daemon.
jan 04 11:43:07 workstation-linux emacs[52433]: Loading /home/jose/.config/emacs/config.el (source)...
jan 04 11:43:08 workstation-linux emacs[52433]: org-super-agenda-mode enabled.
jan 04 11:43:08 workstation-linux emacs[52433]: [yas] Prepared just-in-time loading of snippets successfully.
jan 04 11:43:08 workstation-linux emacs[52433]: Loading /home/jose/.config/emacs/config.el (source)...done
jan 04 11:43:08 workstation-linux emacs[52433]: Loaded /home/jose/.config/emacs/config.el
jan 04 11:43:08 workstation-linux systemd[1529]: Started Emacs text editor.

I may need to look up on lingering as it is a new concept to me.

Offline

#4 2022-01-04 14:36:59

josemota
Member
Registered: 2010-10-24
Posts: 47

Re: [SOLVED] [systemd] Cannot enable user-level services

I have just enabled lingering and rebooted my computer, after which I ran that last status command to see any difference, which it did — but not the one I wanted :'D

$ systemctl --user status emacs                                                                                       ~
○ emacs.service - Emacs text editor
     Loaded: loaded (/home/jose/.config/systemd/user/emacs.service; linked; vendor preset: enabled)
     Active: inactive (dead)
       Docs: info:emacs
             man:emacs(1)
             https://gnu.org/software/emacs/

Offline

#5 2022-01-04 15:34:10

ayekat
Member
Registered: 2011-01-17
Posts: 1,516
Website

Re: [SOLVED] [systemd] Cannot enable user-level services

josemota wrote:
[Install]
WantedBy=default.target%

Is that a copy-paste typo or is there really a percentage sign at the end of that WantedBy line?

Out of curiosity, what is currently in your ~/.config/systemd/user/?


{,META,RE}PKGBUILDSpacman-hacks (includes makemetapkg and remakepkg) │ dotfiles

Offline

#6 2022-01-04 15:38:03

josemota
Member
Registered: 2010-10-24
Posts: 47

Re: [SOLVED] [systemd] Cannot enable user-level services

ayekat wrote:

(...) Is that a copy-paste typo or is there really a percentage sign at the end of that WantedBy line?

That is a representation of EOF, I believe. Meaning, it does not have a newline at the end.

ayekat wrote:

Out of curiosity, what is currently in your ~/.config/systemd/user/?

Here you go.

$ ls -la .config/systemd/user
total 32
drwxr-xr-x 2 jose jose 4096 jan  4 15:37 .
drwxr-xr-x 3 jose jose 4096 nov  2  2020 ..
lrwxrwxrwx 1 jose jose   81 nov  2  2020 default.target.wants -> ../../../workspace/dotfiles/stow/mbsync/.config/systemd/user/default.target.wants
lrwxrwxrwx 1 jose jose   73 nov  2  2020 emacs.service -> ../../../workspace/dotfiles/stow/emacs/.config/systemd/user/emacs.service
lrwxrwxrwx 1 jose jose   71 nov  2  2020 mbsync.env -> ../../../workspace/dotfiles/stow/mbsync/.config/systemd/user/mbsync.env
lrwxrwxrwx 1 jose jose   75 nov  2  2020 mbsync.service -> ../../../workspace/dotfiles/stow/mbsync/.config/systemd/user/mbsync.service
lrwxrwxrwx 1 jose jose   73 jan  4 15:37 mbsync.timer -> ../../../workspace/dotfiles/stow/mbsync/.config/systemd/user/mbsync.timer
lrwxrwxrwx 1 jose jose   80 nov  2  2020 timers.target.wants -> ../../../workspace/dotfiles/stow/mbsync/.config/systemd/user/timers.target.wants

Offline

#7 2022-01-04 15:46:00

seth
Member
Registered: 2012-09-03
Posts: 29,723

Re: [SOLVED] [systemd] Cannot enable user-level services

How do you login? emacs is going to require a display server and if your log into a console and emacs starts before the display server is available, it'll likely just tell you to use "emacs -nw" or so…

Offline

#8 2022-01-04 15:47:29

josemota
Member
Registered: 2010-10-24
Posts: 47

Re: [SOLVED] [systemd] Cannot enable user-level services

seth wrote:

How do you login? emacs is going to require a display server and if your log into a console and emacs starts before the display server is available, it'll likely just tell you to use "emacs -nw" or so…

Emacs is booting as a daemon. I spawn new frames afterwards, once I'm ready to go.

EDIT: I login through LightDM.

Last edited by josemota (2022-01-04 15:47:45)

Offline

#9 2022-01-04 15:53:34

seth
Member
Registered: 2012-09-03
Posts: 29,723

Re: [SOLVED] [systemd] Cannot enable user-level services

ls -l ~/.config/systemd/user/default.target.wants

And I'd add a trailing newline just for good measure …

Offline

#10 2022-01-04 23:59:09

josemota
Member
Registered: 2010-10-24
Posts: 47

Re: [SOLVED] [systemd] Cannot enable user-level services

Here's what I've done:

1. Unstowed my config files (stow -D -d <path/to/stow> -t ~ <key>).
2. Removed the symlinked ~/.config/systemd/user/default.target.wants directory.
3. Created that same directory instead.
4. Restowed my config files back.
5. Reboot.
6. Profit.

Thank you seth. Indeed your suggestion of good measure led me to follow the aforementioned steps.
Thank you all for assisting me.

Marking as solved.

Offline

Board footer

Powered by FluxBB