mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix(tui_gateway): guard sys.path against local package shadowing (#15989)
When the TUI backend (tui_gateway/entry.py) is spawned by Node.js with the user's CWD containing a local utils/ directory, that directory shadows the installed utils module, causing ImportError in run_agent and hermes_cli. Strip '' and '.' from sys.path and prepend HERMES_PYTHON_SRC_ROOT (already set by hermes_cli before spawning the subprocess) so installed packages always win over CWD artifacts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
645a2f482d
commit
60b143e9df
2 changed files with 114 additions and 2 deletions
|
|
@ -1,7 +1,18 @@
|
|||
import json
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
|
||||
# Guard against a local utils/ (or other package) in CWD shadowing installed
|
||||
# hermes modules. hermes_cli sets HERMES_PYTHON_SRC_ROOT before spawning this
|
||||
# subprocess; inserting it first ensures the installed packages win.
|
||||
_src_root = os.environ.get("HERMES_PYTHON_SRC_ROOT", "")
|
||||
if _src_root and _src_root not in sys.path:
|
||||
sys.path.insert(0, _src_root)
|
||||
# Strip '' and '.' — both resolve to CWD at import time and can let a local
|
||||
# directory shadow installed packages.
|
||||
sys.path = [p for p in sys.path if p not in ("", ".")]
|
||||
|
||||
import json
|
||||
import signal
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue