Bugzilla – Bug 1222172
emacsclient -n -c fails to start when emacs daemon is started early
Last modified: 2024-07-19 09:01:21 UTC
TW includes emacs.service to start an emacs server through systemd. I enable the unit file: systemctl enable --user emacs after log out/log in, the server is started properly within the user session. But any attempt to start a client with a frame (-c) disconnected from the shell (-n) fails silently: emacsclient -n -c // fails immediately and returns 1. journald shows: 29 15:54:29 cartola emacs[29953]: xauth: (argv):1: bad display name "wayland-0" in "extract" command 29 15:54:29 cartola emacs[29953]: No matches found, authority file "-" not written 29 15:54:29 cartola emacs[29953]: xauth: (argv):1: unable to read any entries from file "(stdin)" Curiously, if I omit the -n parameter, it kind of works. A tiny window gets created. It seems the frame is misconfigured as it ignored the window setting: emacsclient -c Now... If, from a shell, I restart the service: systemctl restart --user emacs Then, both: emacsclient -n -c emacsclient -c work fine, and respect the window sizes previously set. I suspect the problem is some missing wayland environment variable that is not configured when emacsd is first started. After restart, when everything works, I see the /proc/<pid>/environ is much longer. In particular these are now set in the emacs daemon environment: XAUTHORITY=/run/user/1000/emacs/xauth XAUTHLOCALHOSTNAME=mylaptop I'm using the distro provided unit file: [0:krisman@cartola ~]$ systemctl status --user emacs ● emacs.service - Emacs text editor Loaded: loaded (/usr/lib/systemd/user/emacs.service; enabled; preset: disa> Active: active (running) since Fri 2024-03-29 15:56:04 EDT; 8min ago Docs: info:emacs man:emacs(1)
Usr REAL X not broken wayland ... does this work?
Btw: HOW should a already running emacs daemon know about size of a not stared display?
https://www.emacswiki.org/emacs/EmacsAsDaemon
(In reply to Dr. Werner Fink from comment #2) Should emacs (In reply to Dr. Werner Fink from comment #1) > Usr REAL X not broken wayland ... does this work? Not really. considering wayland is becoming a default everywhere and I need stuff like per-display scaling, X is becoming a worse option everyday, no matter how crappy wayland is... Also, isn't gnome over wayland the default installation on TW? (In reply to Dr. Werner Fink from comment #2) > Btw: HOW should a already running emacs daemon know about size of a not > stared display? Perhaps the emacs daemon service unit should depend on the graphical environment: [unit] After=gnome-session-manager@gnome.service It's been a PITA debugging this because logout-login seems to be preserving some environment somehow, and I simply cannot reproduce without a full reboot. But I'll test this.
I've added After=graphical-session.target in the [Unit] section as this should work with GNOME/KDE as well as with X11 and Wayland
This is an autogenerated message for OBS integration: This bug (1222172) was mentioned in https://build.opensuse.org/request/show/1166776 Factory / emacs
(In reply to OBSbugzilla Bot from comment #6) > This is an autogenerated message for OBS integration: > This bug (1222172) was mentioned in > https://build.opensuse.org/request/show/1166776 Factory / emacs Please test this version to see if the emacs.service in the systemd user serives solve the problem ... be aware to remove any self edited version to really use the new emacs.service
Fixed IMHO