Products › lamco-dbus-tools › Use cases
A D-Bus service missing an environment variable set at login
A D-Bus service missing an environment variable set at login: It started before UpdateActivationEnvironment, as dbussee and dbustell showed on dbus-broker.
A session service says a variable the login script set isn't there, and nothing fails or logs.
lamco-dbus-tools found the cause with dbussee, which recorded the login, and dbustell, whose
activation and ACT-005 finding showed the service started before the environment was
complete.
A real run on 2026-11-30 on fedora45-gnome (a test VM, Fedora 45 Workstation, GNOME, the session bus
dbus-broker 37), with a development build of lamco-dbus-tools, version 0.1.0. The service is made up for this page,
not a real one: reporter.py. run.sh installs it, runs everything below and removes it again, the
variable in the user's service manager included; every output quoted is in the use case's directory.
The symptom
A session service reads where its settings are from its environment, EXAMPLE_SETTINGS_DIR, which a
login script provides by updating the session's activation environment. Yet it says it has none, though
the script ran:
$ gdbus call --session --dest com.example.Reporter --object-path /com/example/Reporter --method com.example.Reporter.Settings
('no settings directory: using defaults',)
Nothing failed and nothing was logged.
A recording of the login
dbussee record --all --duration 12 --out started-early.json
Something asked the service a question before the login script had run. Then the script set the variable, and the service was asked again:
$ dbustell activation started-early.json
com.example.Reporter: started, requested by :1.91 with a call to org.freedesktop.DBus.Introspectable.Introspect
started 4.75 ms after the request: dbus-broker's launcher ran it in a unit of its own making
name taken 106.34 ms after the request, ± 14.6 µs
the activation environment changed 1.11 s after the request: EXAMPLE_SETTINGS_DIR
$ dbustell findings started-early.json
ACT-005 (problem): A service started before the activation environment was complete
com.example.Reporter took its name 1.01 s before the activation environment was changed, setting EXAMPLE_SETTINGS_DIR. A program's environment is set when it starts, so it runs without EXAMPLE_SETTINGS_DIR. A service started later gets it.
Records: 171, 221, 233
The recording keeps the names of the variables an update sets and never their values, whatever it was asked to keep of message bodies: A session's environment can hold tokens and paths.
The cause
A program's environment is fixed when it starts. The first question started the service, through dbus-broker's launcher, without the variable. The login script's update came a second later, on the recording's clock. It reaches the service manager and every service started after it, but not one already running. The service kept answering from its defaults for as long as it ran.
On dbus-broker the update goes on to the user's service manager: Its launcher calls the manager's
SetEnvironment with it (src/launch/launcher.c in dbus-broker 37). Either way, a program already running
never sees it.
The fix
Start the service again once the environment is complete:
$ gdbus call ... --method com.example.Reporter.Quit
$ gdbus call ... --method com.example.Reporter.Settings
('/home/user/.config/example-reports',)
For good: Have the login script set the variable before anything can ask for the service, or have the service read the setting when it needs it rather than once at its start.
What made it findable
- The order of two events a second apart, a start and an update, both on the recording's one clock.
- The update's variables by name, kept by default, with no message bodies recorded.
- The finding names which service missed which variable, so the fix is one restart and a reordering.