Subject: bug#62938: 30.0.50; Emacsclient -nc can fail with to many arguments under Wayland

From: Robert Pluim <[email-masked]>
Date: Wed, 19 Apr 2023 12:01:37 +0200

>>>>> On Tue, 18 Apr 2023 19:08:19 +0300, Björn Bidar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]> said:

    Björn> I start emacsclient -nc using a global shortcut in KDE (S-e in my case)
    Björn> start by the included Emacsclient desktop file.
    Björn> (exec emacsclient --alternate-editor= --display="\$DISPLAY" "\$@"; else exec emacsclient --alternate-editor= --create-frame; fi' sh %F)

    Björn> The command fails silently visually but in the logs there's:
    Björn> Apr 18 18:47:46 odin kwin_wayland_wrapper[22013]: *ERROR*: Assertion failed: (eq (match-end 0)

    Björn> The bug only happens on Wayland, on X11 the issue isn't present.
    Björn> I believe the issue was present before Emacs 29 was branched off.

    Björn> My WM/Compositor is Kwin.

    Björn> Enabling toggle-debug-error shows this backtrace:
    Björn> Debugger entered--Lisp error: (cl-assertion-failed ((eq (match-end 0) (length string)) nil))
    Björn>   cl--assertion-failed((eq (match-end 0) (length string)))

    Björn> I assume the arguments passed to the daemon process are to long because
    Björn> of the amount of environment variables that I set.

How are you starting the daemon emacs? Does this still happen if you
start the daemon as 'emacs --fg-daemon' instead.

The issue is that emacsclient is sending 'Waiting for Emacs...' to the
emacs server socket instead of stdout. Are you using the
EMACS_SOCKET_NAME environment variable or the '--socket-name' option
somehow?

Could you also check which emacsclient is being invoked (eg
emacsclient -V) and ensure it corresponds to your version of Emacs?

Robert
--