emacs-29.0.9999 is built as a pure GTK application with native Wayland support (USE="gtk -X"). If I try to run emacs daemon with /etc/init.d/emacs.user the service starts, but immediately crashes when emacsclient tries to connect to it. This does not happen if I run `emacs --daemon` manually, in such case everything works as expected. I changed /etc/init.d/emacs EMACS_OPTS value to "--fg-daemon -Q" to see the output, here's what happens when emacsclient tries to connect: * Starting Emacs daemon for user user ... Warning: due to a long standing Gtk+ bug<...> (emacs:29216): Gtk-WARNING **: 15:04:34.608: cannot open display: wayland-1 * start-stop-daemon: failed to start `/usr/libexec/emacs/emacs-wrapper.sh' [ !! ] * ERROR: emacs.user failed to start
app-emacs/emacs-daemon outputs this warning for a reason: Your current Emacs is compiled with GTK+. There is a long-standing bug in GTK+ that prevents Emacs from recovering from X disconnects: <https://bugzilla.gnome.org/show_bug.cgi?id=85715> If you run Emacs as a daemon, then it is strongly recommended that you compile it with the Lucid or the Motif toolkit instead, i.e. with USE="athena Xaw3d -gtk -motif" or USE="motif -gtk -athena -Xaw3d". So, please report the problem upstream. As a workaround until this will be fixed, you can build Emacs with the USE flag combination as suggested above.
For reference, there was a discussion on the emacs-devel mailing list some time ago, subject "Question about pgtk -- is it meant to fix the disconnect crash bug?" Especially the following two messages may be of interest: https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00236.html https://lists.gnu.org/archive/html/emacs-devel/2021-03/msg00279.html