fix(gateway): add system dirs to PATH for UV Python compatibility

UV's bundled Python ships a minimal PATH that excludes /bin and /usr/bin,
causing launchctl/systemctl subprocess calls to fail with FileNotFoundError.

Fixes #3849
This commit is contained in:
Kevin Rajaram 2026-03-29 21:59:50 -04:00 committed by Teknium
parent 708b57e009
commit 1b7853d7bc

View file

@ -12,6 +12,14 @@ 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