Alexis writes: > Hi all, Hi Alexis, > For a while i've been manually starting an Emacs server on login (via > my .zlogin), after a D-Bus session has been started (also via my > .zlogin). However, i recently tried moving to the Gentoo OpenRC > service, and have run into a problem regarding D-Bus. > > The 'emacs' OpenRC service gets started at boot, prior to login. There > is thus no D-Bus session bus available at that time; the > DBUS_SESSION_BUS_ADDRESS env var isn't set. As noted above, this > changes once i log in; the DBUS_SESSION_BUS_ADDRESS variable gets > set. However, the Emacs server still thinks that var is unset. > > i had assumed that running: > > emacsclient --eval "(setenv \"DBUS_SESSION_BUS_ADDRESS\" > \"${DBUS_SESSION_BUS_ADDRESS}\")" > > in my WM startup script, to set that var in the environment of the > server process, would address this. > > However, while it addresses some issues - such as Emacs being able to > open a new tab in an existing Firefox instance - it doesn't seem to > affect the D-Bus environment in Emacs more generally: > > (dbus-get-unique-name :session) > -> (dbus-error "No connection to bus" :session) I can reproduce it. On my Fedora desktop, I have reproduced it with running from a shell --8<---------------cut here---------------start------------->8--- # unsetenv DBUS_SESSION_BUS_ADDRESS # emacs -Q --8<---------------cut here---------------end--------------->8--- If I now eval the following in the *scratch* buffer --8<---------------cut here---------------start------------->8--- (setenv "DBUS_SESSION_BUS_ADDRESS" "unix:path=/run/user/1000/bus") (dbus--init-bus :session) --8<---------------cut here---------------end--------------->8--- I get the same error like you --8<---------------cut here---------------start------------->8--- -> (dbus-error "No connection to bus" :session) --8<---------------cut here---------------end--------------->8--- Debugging Fdbus__init_bus in dbusbind.c shows, that the error happens in XD_DBUS_VALIDATE_BUS_ADDRESS. This macro calls on C level --8<---------------cut here---------------start------------->8--- getenv ("DBUS_SESSION_BUS_ADDRESS") --8<---------------cut here---------------end--------------->8--- However, the (setenv ...) form above is on Lisp level, and it writes the change into the internal Lisp variable process-environment. This doesn't match. > What am i missing? Or is it simply not possible to 'restart' dbus.el > from ELisp in order to get it to create a :session bus based on the > updated value of DBUS_SESSION_BUS_ADDRESS in the server process > environment? The appended patch has fixed this for me. Could you, please, check? > Alexis. Best regards, Michael.