Skip to content

fix(cron): pin the external worker's runtime site-packages, not just repo root - #126001

Closed
mathcuei wants to merge 1 commit into
NousResearch:mainfrom
mathcuei:fix/cron-worker-site-packages-pin
Closed

mathcuei wants to merge 1 commit into
NousResearch:mainfrom
mathcuei:fix/cron-worker-site-packages-pin

Conversation

@mathcuei

Copy link
Copy Markdown

Summary

Test plan

  • New regression test tests/cron/test_scheduler_worker_env_site_packages.py: proves the pin restores both repo root and site-packages while preserving pre-existing PYTHONPATH entries, and that the wheel/pipx purelib no-op path is untouched.
  • Verified by hand against the real interpreter/site-packages layout (ruamel.yaml/dotenv import successfully in the pinned env; failed before the fix).
  • Applied on my own production install and re-ran the previously-failing jobs (financial contract audit, Zimbra version check, a 32-failures-in-a-row job) — all now complete successfully.
  • scripts/run_tests.sh tests/cron/test_scheduler_worker_env_site_packages.py — not run in this environment (no local dev venv set up); please run in CI.

🤖 Generated with Claude Code

…repo root

_launch_external_cron_worker builds the worker env through the shared
subprocess sanitizer, which strips Hermes-owned PYTHONPATH entries -- the
repo root AND the runtime's own site-packages -- correctly for a genuine
user child (#3bbec90f2, tools/environments/local_pythonpath.py). The
external cron worker is not a user child, it IS Hermes
(`sys.executable -m cron.scheduler`), and needs both back.

pin_hermes_tree_on_pythonpath (NousResearch#112729) already re-pins the repo root, which
is why cron/utils/agent.* import fine, but left site-packages stripped. The
moment anything on that import chain needs a third-party dependency --
hermes_yaml.py importing ruamel.yaml (#284dbaf5), hermes_cli/env_loader.py
importing dotenv -- the worker dies with ModuleNotFoundError before it can
send its ownership acknowledgement. This broke nearly every cron job on a
managed (systemd) gateway install.

Fix: also pin tools.environments.local_pythonpath::_get_hermes_site_packages
onto the worker's PYTHONPATH, alongside the repo root.

Fixes NousResearch#125999.
@mathcuei

Copy link
Copy Markdown
Author

Closing as duplicate — #122222 already has the same root-cause analysis with independent confirmations from multiple installs, and three open PRs proposing the same class of fix at this exact call site: #122238, #122290, #122382. No need for a fourth. Linking here for anyone who lands on this PR from #125999.

@mathcuei mathcuei closed this Sep 28, 2026
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/cron Cron scheduler and job management sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management P1 High — major feature broken, no workaround sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cron: external worker's PYTHONPATH pin (#112729 follow-up) drops site-packages, breaking ruamel/dotenv imports for almost every job

2 participants