Repository navigation
kanban: fix worker spawn ModuleNotFoundError by setting PYTHONPATH - #144142
Open
u12contactme-collab wants to merge 1 commit into
Open
u12contactme-collab wants to merge 1 commit into
u12contactme-collab wants to merge 1 commit into
Conversation
The hermes.cmd/hermes.exe launcher makes hermes_cli importable via an
in-process sys.path.insert(0, <hermes-agent root>) after explicitly
popping any inherited PYTHONPATH. That fixup only affects the current
process, never a child spawned later.
The kanban dispatcher spawns every worker as a bare
`sys.executable -m hermes_cli.main` (_module_hermes_argv), bypassing
the launcher shim entirely. The fresh child interpreter has no way to
import hermes_cli and crashes immediately with:
ModuleNotFoundError: No module named 'hermes_cli'
This hits every kanban-dispatched worker on managed-runtime installs,
not just newly created profiles. Matches several independently filed
reports of the same symptom (NousResearch#125121, NousResearch#122620, NousResearch#122500, NousResearch#30943,
NousResearch#134503, NousResearch#122299, NousResearch#137079, NousResearch#135640, NousResearch#124542).
Fix: give the child the one thing that does survive a spawn (an env
var) pointing at the same root the launcher inserts into sys.path,
right where the worker's environment is otherwise built. Deliberately
leaves _module_hermes_argv's choice of sys.executable -m hermes_cli.main
untouched -- that is a documented, deliberate mitigation for a
PATH-shadowing attack (NousResearch#111569), so this adds the missing piece instead
of changing the invocation.
Verified live: previously the worker crashed within 61-82s on every
attempt. After this fix the same task ran for minutes with real
heartbeats and CPU time before completing normally.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hermes.cmd/hermes.exe) makeshermes_cliimportable via an in-processsys.path.insert(0, <hermes-agent root>), after explicitly popping any inheritedPYTHONPATH. That only affects the current process.sys.executable -m hermes_cli.main(_module_hermes_argv), bypassing the launcher shim entirely, so the fresh child interpreter can't importhermes_cliand crashes immediately withModuleNotFoundError: No module named 'hermes_cli'.ModuleNotFoundError: No module named 'hermes_cli'when the gateway runs on the PM store Python #122620, Kanban workers crash after hermes update: dispatcher picks '-m hermes_cli.main' from a find_spec probe polluted by the gateway bootstrap sys.path #122500, Windows: kanban workers crash with ModuleNotFoundError when gateway runs from venv (pip console_script launcher fails with restricted PATH) #30943, kanban dispatcher spawns broken workers under managed runtime (python -m hermes_cli.main without sys.path) #134503, kanban dispatcher: worker spawn argv guard checks importability in parent, unsound for bare-interpreter child (ModuleNotFoundError: hermes_cli) #122299, Kanban dispatch spawns workers via sys.executable -m hermes_cli.main, broken under PM-managed runtime #137079, kanban dispatcher worker spawn fails under a bootstrap install: 'sys.executable -m hermes_cli.main' child cannot import hermes_cli #135640, Kanban worker spawn crashes with ModuleNotFoundError: hermes_cli.main (git-checkout installs) #124542.Fix
Set
PYTHONPATHon the worker's environment (right where the rest of the worker env is already built inkanban_db_dispatch.py) to the same root the launcher inserts intosys.path. Deliberately does not change_module_hermes_argv's choice ofsys.executable -m hermes_cli.main— that invocation is a documented, deliberate mitigation for a PATH-shadowing attack (#111569), so this adds the missing piece instead of changing it.Test plan
🤖 Generated with Claude Code