My emacs.service looks like this:
denis@dgecko:~> cat /home/denis/.config/systemd/user/emacs.service
[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/
[Service]
Type=forking
# I added -q argument to exclude any errors in my init.el
# executing my locally compiled version
ExecStart=/home/denis/.local/bin/emacs -q --daemon
ExecStop=/home/denis/.local/bin/emacsclient --eval "(kill-emacs)"
Environment=SSH_AUTH_SOCK=%t/keyring/ssh
Restart=on-failure
User=denis
Group=users
[Install]
WantedBy=default.target
When executing daemon manually, everything is OK:
denis@dgecko:~> /home/denis/.local/bin/emacs --daemon
Due to a limitation in GTK 3, Emacs built with PGTK will simply exit when a
display connection is closed. The problem is especially difficult to fix,
such that Emacs on Wayland with multiple displays is unlikely ever to be able
to survive disconnects.
Loading delsel (native compiled elisp)...
Loading delsel (native compiled elisp)...done
■ Warning (initialization): The `light-blue' theme is obsolete since Emacs 29.1
[yas] Prepared just-in-time loading of snippets successfully.
Loading /home/denis/.emacs.d/recentf...
Loading /home/denis/.emacs.d/recentf...done
Cleaning up the recentf list...
Cleaning up the recentf list...done (0 removed)
.emacs.d/elpa/irony-20220110.849/irony-iotask.el: Warning: Case 'value will match ‘quote’. If that’s intended, write (value quote) instead. Otherwise, don’t quote ‘value’.
.emacs.d/elpa/irony-20220110.849/irony-iotask.el: Warning: Case 'error will match ‘quote’. If that’s intended, write (error quote) instead. Otherwise, don’t quote ‘error’.
.emacs.d/elpa/irony-20220110.849/irony.el: Warning: Use keywords rather than deprecated positional arguments to `define-minor-mode'
Starting Emacs daemon.
However, when trying to launch it with systemd:
denis@dgecko:~> /home/denis/.local/bin/emacsclient --eval "(kill-emacs)"
denis@dgecko:~> ps aux | grep emacs
denis 19301 0.0 0.0 6560 2136 pts/0 S+ 12:32 0:00 grep --color=auto emacs
denis@dgecko:~> systemctl start --user emacs
Job for emacs.service failed because the control process exited with error code.
See "systemctl --user status emacs.service" and "journalctl --user -xeu emacs.service" for details.
denis@dgecko:~> journalctl --user -xeu emacs.service
Mar 08 12:33:06 dgecko systemd[1626]: Stopped Emacs text editor.
░░ Subject: A stop job for unit UNIT has finished
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A stop job for unit UNIT has finished.
░░
░░ The job identifier is 619 and the job result is done.
Mar 08 12:33:06 dgecko systemd[1626]: emacs.service: Start request repeated too quickly.
Mar 08 12:33:06 dgecko systemd[1626]: emacs.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ The unit UNIT has entered the 'failed' state with result 'exit-code'.
Mar 08 12:33:06 dgecko systemd[1626]: Failed to start Emacs text editor.
░░ Subject: A start job for unit UNIT has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit UNIT has finished with a failure.
░░
░░ The job identifier is 619 and the job result is failed.
denis@dgecko:~> systemctl --user status emacs.service
× emacs.service - Emacs text editor
Loaded: loaded (/home/denis/.config/systemd/user/emacs.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Wed 2023-03-08 12:33:06 CET; 18s ago
Docs: info:emacs
man:emacs(1)
https://gnu.org/software/emacs/
Process: 19314 ExecStart=/home/denis/.local/bin/emacs -q --daemon (code=exited, status=216/GROUP)
CPU: 0
Mar 08 12:33:06 dgecko systemd[1626]: emacs.service: Scheduled restart job, restart counter is at 5.
Mar 08 12:33:06 dgecko systemd[1626]: Stopped Emacs text editor.
Mar 08 12:33:06 dgecko systemd[1626]: emacs.service: Start request repeated too quickly.
Mar 08 12:33:06 dgecko systemd[1626]: emacs.service: Failed with result 'exit-code'.
Mar 08 12:33:06 dgecko systemd[1626]: Failed to start Emacs text editor.
EDIT: status=216
, looks like something related to Group, but removing it from unit file doesn't help, and the group users
does exist, and i am within that group. Any help?
Some general info:
denis@dgecko:~> emacs --version
GNU Emacs 29.0.50
Development version d04433b96215 on master branch; build date 2022-11-16
denis@dgecko:~> uname -a
Linux dgecko 6.1.12-1-default #1 SMP PREEMPT_DYNAMIC Wed Feb 15 05:31:41 UTC 2023 (373f017) x86_64 x86_64 x86_64 GNU/Linux
# this works fine
denis@dgecko:~> sudo runuser -l denis -g users -c "DISPLAY=$DISPLAY /home/denis/.local/bin/emacs"
denis@dgecko:~> ll /home/denis/.local/bin/emacs
lrwxrwxrwx 1 denis users 13 Nov 16 14:34 /home/denis/.local/bin/emacs -> emacs-29.0.50
denis@dgecko:~> ll /home/denis/.local/bin/emacs-29.0.50
-rwxr-xr-x 1 denis users 27609992 Nov 16 14:34 /home/denis/.local/bin/emacs-29.0.5
denis@dgecko:~> getent group users
users:x:100:git