I am running systemd via user (i.e. enable-linger $USER) and I interact with services via systemctl --user
I noticed a strange issue.
Sourcing Type 1
In order for the above systemd to work for a user, I need to add export XDG_RUNTIME_DIR=/run/user/$(id -u) inside my ~/.bashrc
This works fine.
Sourcing Type 2
When I instead source my bashrc as follows, the systemd does not work:
inside .bashrc:
source /path_to_file/my_file.env inside my_file.env:
XDG_RUNTIME_DIR=/run/user/$(id -u) Both Sourcing Type 1 and 2 yield the same result when I do echo $XDG_RUNTIME_DIR so I decided to go with Type 2. However then I noticed that when I do systemctl --user daemon-reload the daemon was not running and I got the following error:
Failed to connect to bus: No such file or directory When I revert back to Souring Type 1, the error is gone and all works as expected.
My question is: What is happening that I am missing here? My main confusion stems from the fact that the env variables are the same, but the end results are not.
.envfiles are not shell scripts and should not be sourced at all. Quoting rules are different, so the value assigned to a name by a.envparser may be different than what the shell will assign.