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?