You are not logged in.
I cannot for the life of me figure out why a systemd user service cannot find an executable on my path.
$ ls -la /home/bart/.deno/bin
total 4
drwxr-xr-x 1 bart bart 20 20 mrt 11:47 .
drwxr-xr-x 1 bart bart 6 20 mrt 11:12 ..
-rwxr-xr-x 1 bart bart 122 20 mrt 11:47 lfl-serverWorks:
$ PATH=/home/bart/.deno/bin:/usr/bin lfl-server
I[2022-03-20T10:57:48.365Z] servest:router listening on :9090This does not (cannot find lfl-server):
$ cat ~/.config/systemd/user/lfl-server.service
[Unit]
Description=Local File Links Server
[Service]
Environment=PATH=/home/bart/.deno/bin:/usr/bin
ExecStart=lfl-server
[Install]
WantedBy=default.targetWhen I remove the 'Environment' line, use systemctl --user import-environment and then
$ systemctl --user show-environment | grep PATH
PATH=/home/bart/bin:/home/bart/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/opt/google-cloud-sdk/bin:/home/bart/.deno/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perlI can see it is there. But again:
$ systemctl start --user lfl-server
$ journalctl --user-unit lfl-server
mrt 20 11:59:44 mango systemd[1591]: Started Local File Links Server.
mrt 20 11:59:44 mango systemd[4684]: lfl-server.service: Failed to locate executable lfl-server: No such file or directory
mrt 20 11:59:44 mango systemd[4684]: lfl-server.service: Failed at step EXEC spawning lfl-server: No such file or directory
mrt 20 11:59:44 mango systemd[1591]: lfl-server.service: Main process exited, code=exited, status=203/EXEC
mrt 20 11:59:44 mango systemd[1591]: lfl-server.service: Failed with result 'exit-code'.Does anybody understand what is going on here? And why systemd cannot find the executable even though the containing folder is on the PATH? Even when I use
ExecStart=echo $PATHI can see the PATH is correct.
Last edited by sleeping (2022-03-20 14:30:44)
Offline
Systemd has never looked at the PATH variable for resolving non absolute binaries. From
If the command is not a full (absolute) path, it will be resolved to a full path using a fixed search path
determined at compilation time. Searched directories include /usr/local/bin/, /usr/bin/, /bin/ on systems
using split /usr/bin/ and /bin/ directories, and their sbin/ counterparts on systems using split bin/ and
sbin/. It is thus safe to use just the executable name in case of executables located in any of the
"standard" directories, and an absolute path must be used in other cases. Using an absolute path is
recommended to avoid ambiguity. Hint: this search path may be queried using systemd-path
search-binaries-default.
Last edited by V1del (2022-03-20 11:11:32)
Offline
Thanks!
Maybe the wiki should be updated to reflect this.
Offline
I don't see a logical conflict here, PATH will be imported and set for the executable you end up running, but systemd itself does not use it to invoke the binary, maybe one could add a note that this doesn't affect systemd's own lookup path.
Offline