Subject: bug#35300: 27.0.50; emacsclient on remote sessions no longer works

From: Óscar Fuentes <[email-masked]>
Date: Fri, 19 Apr 2019 17:40:05 +0200

Eli Zaretskii <[email-masked]> writes:

>> > So you didn't have XDG_RUNTIME_DIR set?  In that case, I feel I
>> > understand the issue even less, because when XDG_RUNTIME_DIR is not
>> > defined, emacsclient is supposed to fall back to the old behavior...
>> 
>> IIUC, the Emacs server creates the local socket under the directory
>> pointed by XDG_RUNTIME_DIR. When emacsclient starts, if XDG_RUNTIME_DIR
>> is not set it simply does not know where to find the socket.
>
> So you are saying that XDG_RUNTIME_DIR did exist when the server was
> started,

Yes.

> but ceased to exist by the time emacsclient was started?

It didn't cease to exist. That variable is automatically set when you
log in and certain components are installed and enabled.

I ssh-ed to the machine and no XDG_RUNTIME_DIR was set on that session
because the machinery that sets it up when you log in through ssh was
disabled.

That is: at the time there was two sessions, one local with
XDG_RUNTIME_DIR set and from where the Emacs server was started and a
remote session with no XDG_RUNTIME_DIR and, therefore, with emacsclient
unable to connect to the Emacs server unless you tell it where the local
socket is.

As explained on the bug report referenced by Glenn, there are other
scenarios where XDG_RUNTIME_DIR is not set (in that case, when the Emacs
server starts as a service.)

You can read more about XDG_RUNTIME_DIR here:

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables