hermes - ✅(Solved) Fix fix(cron): bash script path mangled by backslash escaping on native Windows [2 pull requests, 1 participants]

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…
GitHub stats
NousResearch/hermes-agent#23404Fetched 2026-05-11 03:29:37
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×2

Error Message

On native Windows with Git Bash, cron jobs that use .sh / .bash scripts always fail with exit code 127 and the error:

Root Cause

In cron/scheduler.py::_run_job_script, line 772 passes str(path) as a CLI argument to bash. On Windows, str(path) produces a native path with backslashes (C:\Users\...). Bash (Git Bash / MSYS2) interprets every backslash as an escape character, mangling the path.

Fix Action

Fixed

PR fix notes

PR #23405: fix(cron): use POSIX paths for bash scripts on native Windows

Description (problem / solution / changelog)

Summary

On native Windows with Git Bash, .sh / .bash cron scripts always fail because bash interprets backslashes in the path argument as escape sequences, mangling C:\Users\... into C:Users... (exit code 127, script not found).

This PR gates a one-line fix behind os.name == "nt": use path.as_posix() to produce forward-slash paths (/c/Users/...) that MSYS2 bash understands natively. Non-Windows platforms are completely unaffected — they continue to use str(path).

How to Test

  1. On native Windows with Git Bash, create a cron job with no_agent: true and a .sh script
  2. Confirm the script runs successfully instead of failing with exit code 127

Or use the existing test suite:

python -m pytest tests/cron/test_cron_no_agent.py -v

The test test_run_job_script_shell_script_runs_via_bash already exercises this code path and passes both before and after the change (the test uses POSIX paths, so the fix is invisible to it — as intended).

Platform Tested

  • OS: Windows 11 (native, git-bash)
  • Python: 3.11.14
  • Hermes: v0.13.0

Pre-submit checks

  • scripts/check-windows-footguns.py — zero footguns found
  • tests/cron/test_cron_no_agent.py — all 18 tests pass

Related

Closes #23404

Changed files

  • cron/scheduler.py (modified, +10/-1)

PR #23489: fix(cron): normalize bash script paths on Windows

Description (problem / solution / changelog)

What does this PR do?

Fixes native Windows Git Bash cron .sh / .bash script execution by normalizing the script argument to a forward-slash path before invoking bash.

Without this, _run_job_script() passes a native Windows path like C:\Users\denis\.hermes\scripts\hermes-backup.sh, and Git Bash treats the backslashes as escape characters, mangling the path into C:Usersdenis... and failing with exit code 127.

Related Issue

Fixes #23404

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added _format_bash_script_path() in /cron/scheduler.py to centralize bash path formatting.
  • Switched .sh / .bash execution in _run_job_script() to use a bash-safe path argument on Windows.
  • Added regression tests in /tests/cron/test_scheduler.py for Windows and POSIX path formatting behavior.

How to Test

  1. Run uv run --frozen pytest -q -o addopts='' tests/cron/test_scheduler.py
  2. Run uv run --frozen ruff check cron/scheduler.py tests/cron/test_scheduler.py
  3. On native Windows with Git Bash, configure a cron job using a .sh script and verify the script path reaches bash in forward-slash form instead of losing backslashes.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS (targeted regression tests); Windows path behavior covered by explicit unit tests

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

  • uv run --frozen pytest -q -o addopts='' tests/cron/test_scheduler.py -> 123 passed
  • uv run --frozen ruff check cron/scheduler.py tests/cron/test_scheduler.py -> All checks passed!
  • The repo-wide local pytest tests/ -q entrypoint still fails during collection on both this branch and a clean origin/main worktree with the same preexisting environment-level errors (tomllib, acp, websockets.asyncio, StrEnum), so I left that checklist item unchecked rather than claiming a false full-green run.

Changed files

  • cron/scheduler.py (modified, +9/-2)
  • tests/cron/test_scheduler.py (modified, +20/-1)

Code Example

/bin/bash: C:Usersdenis.hermesscriptshermes-backup.sh: No such file or directory
RAW_BUFFERClick to expand / collapse

Bug Description

On native Windows with Git Bash, cron jobs that use .sh / .bash scripts always fail with exit code 127 and the error:

/bin/bash: C:Usersdenis.hermesscriptshermes-backup.sh: No such file or directory

The actual path is C:\Users\denis\.hermes\scripts\hermes-backup.sh, but bash interprets each backslash as an escape sequence, silently stripping them all.

Root Cause

In cron/scheduler.py::_run_job_script, line 772 passes str(path) as a CLI argument to bash. On Windows, str(path) produces a native path with backslashes (C:\Users\...). Bash (Git Bash / MSYS2) interprets every backslash as an escape character, mangling the path.

Steps to Reproduce

  1. Install Hermes on native Windows (not WSL) with Git Bash
  2. Create a cron job with no_agent: true and a .sh script
  3. Observe the script fails with exit code 127 and a mangled path in stderr

Proposed Fix

Use path.as_posix() on Windows to produce forward-slash paths (/c/Users/...) that MSYS2 bash understands natively. On non-Windows platforms, str(path) is already a valid POSIX path and is left unchanged. The fix is gated behind os.name == "nt" so it has zero impact on Linux/macOS.

Environment

  • OS: Windows 11 (native, git-bash)
  • Hermes: v0.13.0
  • Python: 3.11.14

Related

See also #16201 (broader Windows path issues), #16458 (backslash stripping in message rendering).

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING