I have a very simple systemd service:
[Unit]
Description=throttle service
[Service]
ExecStart=%h/.local/bin/throttle --server
Type=simple
Restart=always
RestartSec=3
[Install]
WantedBy=default.target
The executed service runs the command mbsync [something] in a python subprocess with shell=False.
I have 3 copies of mbsync installed:
❯ which -a mbsync
/home/fbence/.local/bin/mbsync
/home/fbence/.local/bin/mbsync
/usr/bin/mbsync
/bin/mbsync
Running mbsync from the login shell will obviously run the top one in ~/.local. If I manually start the systemd service, as in systemctl --user start throttle.service it also picks up this one. If I reboot my system, then it seems to pick up one of the other (older) versions as I see errors in journalctl, where it is trying to access the config file for older version. If I manually stop and restart the service (systemctl --user stop/start) it works again correctly.
Why is this not consistent? What's the difference between me starting it and it starting on boot? How do I fix this to work also on boot?
Update
After some debugging I found that /usr/libexec/gdm-x-session logs some info about running dbus-update-activation-environment. I tested and adding an ExecStartPre=/bin/sleep 30 solves the issue. So now my question is actually: how do I setup the service to wait for this to happen in a less hacky way?
~/.profile(which is where Ubuntu adds ~/.local/bin to the PATH). You could try creating a custom~/.config/environment.d/file containing the modified PATH as described here Environment variables – steeldriver Mar 05 '24 at 12:46dbus-update-activation-environmentcan set some stuff, but I can't figure out what I need to wait on. – fbence Mar 05 '24 at 14:07WantedBy=graphical-session.targetinstead ofWantedBy=default.targetor useAfter=graphical-session.targetor both for example. – Raffa Mar 05 '24 at 14:23systemctl --user status graphical-session.target– Raffa Mar 05 '24 at 14:36graphical-session.targetwithgraphical.target– steeldriver Mar 05 '24 at 15:01