You are not logged in.

#1 2022-03-20 11:01:48

sleeping
Member
Registered: 2016-01-09
Posts: 53

[SOLVED] systemd/User not finding executable on path

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-server

Works:

$ PATH=/home/bart/.deno/bin:/usr/bin lfl-server
I[2022-03-20T10:57:48.365Z] servest:router listening on :9090

This 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.target

When 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_perl

I 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 $PATH

I can see the PATH is correct.

Last edited by sleeping (2022-03-20 14:30:44)

Offline

#2 2022-03-20 11:11:03

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,878

Re: [SOLVED] systemd/User not finding executable on path

Systemd has never looked at the PATH variable for resolving non absolute binaries. From

man systemd.service wrote:

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

#3 2022-03-20 14:30:19

sleeping
Member
Registered: 2016-01-09
Posts: 53

Re: [SOLVED] systemd/User not finding executable on path

Thanks!

Maybe the wiki should be updated to reflect this.

Offline

#4 2022-03-20 14:44:45

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,878

Re: [SOLVED] systemd/User not finding executable on path

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

Board footer

Powered by FluxBB