Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 831727

Summary: app-emacs/emacs-daemon-0.22 fails to run pgtk emacs in wayland environment
Product: Gentoo Linux Reporter: Yury Katuar <ave>
Component: Current packagesAssignee: GNU Emacs project <gnu-emacs>
Status: RESOLVED UPSTREAM    
Severity: normal CC: sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Yury Katuar 2022-01-21 12:15:18 UTC
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
Comment 1 Ulrich Müller gentoo-dev 2022-01-22 11:16:47 UTC
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.
Comment 2 Ulrich Müller gentoo-dev 2022-01-22 11:45:15 UTC
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