From 619db0175d2fe9e41fcb4f63783ec0d44bea7133 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Sat, 4 Jul 2026 14:58:44 -0700 Subject: [PATCH] fix(gateway): move PATH bootstrap below imports, gate to POSIX Follow-up to #3850's cherry-pick: keeps the fix but avoids the mid-import E402 wart and skips the POSIX system dirs on Windows. --- hermes_cli/gateway.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hermes_cli/gateway.py b/hermes_cli/gateway.py index f85573634af..b3798d4a7c3 100644 --- a/hermes_cli/gateway.py +++ b/hermes_cli/gateway.py @@ -12,20 +12,21 @@ import shlex import shutil import signal import subprocess - -# Ensure /bin and /usr/bin are on PATH so launchctl/systemctl are discoverable -# when running under UV's bundled Python which ships a minimal PATH. -_sys_dirs = {"/bin", "/usr/bin", "/usr/sbin", "/sbin"} -_path_dirs = set(os.environ.get("PATH", "").split(os.pathsep)) -_missing = _sys_dirs - _path_dirs -if _missing: - os.environ["PATH"] = os.environ.get("PATH", "") + os.pathsep + os.pathsep.join(sorted(_missing)) import sys import textwrap import time from dataclasses import dataclass from pathlib import Path +# Ensure /bin and /usr/bin are on PATH so launchctl/systemctl are discoverable +# when running under UV's bundled Python which ships a minimal PATH (#3849). +if os.name == "posix": + _sys_dirs = {"/bin", "/usr/bin", "/usr/sbin", "/sbin"} + _path_dirs = set(os.environ.get("PATH", "").split(os.pathsep)) + _missing = _sys_dirs - _path_dirs + if _missing: + os.environ["PATH"] = os.environ.get("PATH", "") + os.pathsep + os.pathsep.join(sorted(_missing)) + PROJECT_ROOT = Path(__file__).parent.parent.resolve() from gateway.status import terminate_pid