hermes - 💡(How to fix) Fix [Bug]: cron job workdir ignored for pre-run script subprocess

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

workdir has no effect on the subprocess spawned by _run_job_script() — data-collection scripts for cron jobs always run from ~/.hermes/scripts/ regardless of the job's configured workdir. This means scripts can't find project venvs, .env files, or project-relative paths.

Root Cause

Two issues compound:

  1. _run_job_script() hardcodes cwd=str(path.parent) (line 631 of cron/scheduler.py), which is always the script's own directory under ~/.hermes/scripts/.

  2. _job_workdir is extracted too late in run_job() — after the script has already been called. The workdir extraction block sits at line 913, but _run_job_script() is called at line 854.

The no_agent path (_run_no_agent_job) has a separate partial workaround via os.chdir(), but the main agent-job path has this broken ordering.

Fix Action

Fix / Workaround

The no_agent path (_run_no_agent_job) has a separate partial workaround via os.chdir(), but the main agent-job path has this broken ordering.

Code Example

python3 -c "open('$HOME/.hermes/scripts/show_cwd.py','w').write('import os\nprint(f\"CWD={os.getcwd()}\")')"

---

hermes cron create '0 3 * * *' --no-agent --workdir /tmp --script show_cwd.py

---

hermes cron run <job_id>
RAW_BUFFERClick to expand / collapse

Summary

workdir has no effect on the subprocess spawned by _run_job_script() — data-collection scripts for cron jobs always run from ~/.hermes/scripts/ regardless of the job's configured workdir. This means scripts can't find project venvs, .env files, or project-relative paths.

Steps to reproduce

  1. Create a script that prints os.getcwd():
    python3 -c "open('$HOME/.hermes/scripts/show_cwd.py','w').write('import os\nprint(f\"CWD={os.getcwd()}\")')"
  2. Create a cron job with both workdir and --script:
    hermes cron create '0 3 * * *' --no-agent --workdir /tmp --script show_cwd.py
  3. Run it:
    hermes cron run <job_id>
  4. Check the output

Expected behavior

Script runs from /tmp (the configured workdir), output shows CWD=/private/tmp.

Actual behavior

Script runs from ~/.hermes/scripts/ — the hardcoded cwd=str(path.parent) in _run_job_script(). Output shows CWD=/Users/.../scripts.

Root cause

Two issues compound:

  1. _run_job_script() hardcodes cwd=str(path.parent) (line 631 of cron/scheduler.py), which is always the script's own directory under ~/.hermes/scripts/.

  2. _job_workdir is extracted too late in run_job() — after the script has already been called. The workdir extraction block sits at line 913, but _run_job_script() is called at line 854.

The no_agent path (_run_no_agent_job) has a separate partial workaround via os.chdir(), but the main agent-job path has this broken ordering.

Hermes version

main branch (commit before fix: 2564132a1)

Operating system

macOS 15.2

Model / Provider

N/A (cron infrastructure, no LLM involved)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Script runs from /tmp (the configured workdir), output shows CWD=/private/tmp.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING