Trouble with dbus and systemd/user

10,969

Solution 1

If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use D-Bus, by default that process will attempt to invoke dbus-launch with the --autolaunch option to start up a new session bus or find the existing bus address on the X display or in a file in ~/.dbus/session-bus/.

When dbus is not being used with Xorg, as much in the same manner as $DISPLAY works to use a different server, you can set this environment variable in order to tell dbus which bus session to use:

export DBUS_SESSION_BUS_ADDRESS=""

For more info, read http://dbus.freedesktop.org/doc/dbus-launch.1.html

Solution 2

If not using X with dbus,

You can set this environment variable in order to tell dbus which bus session to use :

export DBUS_SESSION_BUS_ADDRESS=
Share:
10,969

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    Community over 1 year

    I have systemd set up so that using systemctl start user@me will start my user services as I expect, but my dbus one just won't go (which I need for PulseAudio).

    Is there some way I can check dbus or systemd to figure out what I'm doing wrong?

    At this point I'm out of ideas for things to try. Please let me know if there's anything else I can provide that might be relevant.


    Additional Info/Resolution Attempt

    I'm using Arch Linux, systemd 204-1, and dbus 1.6.10-1

    Starting user systemd through # systemctl start user@me gives me this:

    ├─systemd─┬─(sd-pam)
    │         ├─mpd───5*[{mpd}]
    │         └─pulseaudio─┬─gconf-helper
    │                      └─2*[{pulseaudio}]
    

    Starting systemd --user & manually as my user produces:

    ├─bash─┬─pstree
    │      └─systemd─┬─2*[dbus-daemon]
    │                ├─dbus-launch <<< X only
    │                ├─gconfd-2    <<< X only
    │                ├─mpd───5*[{mpd}]
    │                └─pulseaudio─┬─gconf-helper
    │                             └─2*[{pulseaudio}]
    

    And spits out the following error if I'm not in X, despite the fact that I did enable my user dbus.service:

    Failed to open private bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    Failed to open private bus connection: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
    

    Related Links:

    1. https://superuser.com/questions/476379/how-do-i-setup-a-systemd-service-to-be-started-by-a-non-root-user-as-a-user-daem
    2. https://github.com/sofar/user-session-units
    3. https://github.com/grawity/systemd-user-units

    The first two mention a problem with dbus, but at link 2 it says that the problem is fixed in dbus-1.6.9, so I think the problem is with my implementation rather than this bug.

    I used example user services from links 2 & 3.