fix(terminal): background commands keep spawn PATH dirs a login profile resets

Background terminal commands run `bash -lic` with no env snapshot, so a
~/.profile or distro /etc/profile that resets PATH dropped every parent-only
dir (bare `hermes` / the venv's tools: command not found), while the same
command in the foreground now resolved. spawn_local gains an opt-in
restore_login_path that prepends the SAME _append_dropped_path_entries
prelude the foreground snapshot uses, fed from the spawn env's PATH; the
terminal tool's local background spawn turns it on. The registry's shell
argv shape is unchanged.
This commit is contained in:
Teknium
2026-10-28 08:12:46 -07:00
parent b1ee09602e
commit 29fef14fbf
4 changed files with 44 additions and 6 deletions

View File

@@ -871,7 +871,9 @@ def _append_dropped_path_entries(cmd_string: str, parent_path: str) -> str:
``/opt/hermes/bin`` and bare ``hermes`` exits 127 (#56634). Dropped dirs go AFTER
the login PATH in parent order, so a command that resolved before still resolves
to the same binary (the user's nvm/pyenv keep precedence); only commands that had
no match gain one. Present entries are never duplicated; missing dirs are skipped."""
no match gain one. Present entries are never duplicated; missing dirs are skipped.
Background commands (``ProcessRegistry.spawn_local``, ``bash -lic``, no snapshot) use
this same prelude so the two paths cannot diverge."""
if _IS_WINDOWS:
return cmd_string # native PATH stays ``;``-joined; bash sees a converted copy
entries = [d for d in dict.fromkeys(parent_path.split(":")) if d and os.path.isdir(d)]