Skip to content

Commit

Permalink
clearer comments and conditions for resolving $PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Jun 7, 2023
1 parent 5077aec commit 1cc4056
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion systemdspawner/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,14 @@ async def start_transient_service(
# systemd-run does not use the unit's $PATH environment
# to resolve relative paths.
if not os.path.isabs(cmd[0]):
path = os.getenv("PATH", os.defpath)
if environment_variables and "PATH" in environment_variables:
# if unit specifies a $PATH, use it
path = environment_variables["PATH"]
else:
# search current process $PATH by default.
# this is the default behavior of shutil.which(path=None)
# but we still need the value for the error message
path = os.getenv("PATH", os.defpath)
exe = cmd[0]
abs_exe = shutil.which(exe, path=path)
if not abs_exe:
Expand Down

0 comments on commit 1cc4056

Please sign in to comment.