From b10ff835663e3f69e58c76d5298b50346739accb Mon Sep 17 00:00:00 2001 From: teknium1 Date: Sun, 8 Mar 2026 01:50:38 -0800 Subject: [PATCH] fix: enhance PATH handling in local environment Updated the LocalEnvironment class to ensure the PATH variable includes standard directories. This change addresses issues with systemd services and terminal multiplexers that inherit a minimal PATH, improving the execution environment for subprocesses. --- tools/environments/local.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/environments/local.py b/tools/environments/local.py index ad40948308..945e3349ff 100644 --- a/tools/environments/local.py +++ b/tools/environments/local.py @@ -175,11 +175,19 @@ class LocalEnvironment(BaseEnvironment): f" printf '{_OUTPUT_FENCE}';" f" exit $__hermes_rc" ) + # Ensure PATH always includes standard dirs — systemd services + # and some terminal multiplexers inherit a minimal PATH. + _SANE_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + run_env = dict(os.environ | self.env) + existing_path = run_env.get("PATH", "") + if "/usr/bin" not in existing_path.split(":"): + run_env["PATH"] = f"{existing_path}:{_SANE_PATH}" if existing_path else _SANE_PATH + proc = subprocess.Popen( [user_shell, "-lic", fenced_cmd], text=True, cwd=work_dir, - env=os.environ | self.env, + env=run_env, encoding="utf-8", errors="replace", stdout=subprocess.PIPE,