Conversation
…-bash On Windows, _run_job_script() passed str(path) (backslash form, e.g. C:\Users\...\x.sh) directly to git-bash, which treats '\' as an escape char and collapses the path so the script is never found (exit 127). Normalize to MSYS form (/c/Users/...) before invoking bash. Fixes .sh/.bash cron jobs on Windows. Refs NousResearch#62514
Duplicate of #23405 (earliest-open PR for the Windows-cron git-bash POSIX/MSYS path mechanism at the same |
teknium1
left a comment
There was a problem hiding this comment.
Thanks for addressing a real native-Windows cron failure. Current main still constructs shell-script argv as [_bash, str(path)] in cron/scheduler.py:2091, so the fix targets the live defect and covers both no-agent and pre-run script callers.
Problems
- No regression test covers the new Windows-only conversion. The existing shell tests at
tests/cron/test_cron_no_agent.py:288-309execute.sh/.bashscripts but do not verify the path passed to bash.
Suggested changes
- Add a focused Windows regression test that captures bash argv and asserts a native
C:\\...script path is converted to/c/...; retain an assertion that POSIX argv is unchanged.
Automated hermes-sweeper review.
| # "C:Users..." so the file is never found (exit 127). Convert to the | ||
| # MSYS form git-bash expects (/c/Users/...) before invoking bash. | ||
| bash_path = str(path) | ||
| if sys.platform == "win32": |
There was a problem hiding this comment.
Please add regression coverage for this Windows-only branch. Existing shell-script tests execute .sh/.bash files but do not assert the argv passed to bash; capture subprocess.run and verify a native drive path becomes /c/....
Capture the argv handed to git-bash and assert a native C:\... script path is converted to /c/... (the exit-127 fix in NousResearch#62516). Also assert POSIX argv is passed through unchanged, plus a focused unit test on the extracted _bash_arg_for_script_path helper.
…sResearch#62516) Capture the argv passed to subprocess.run and assert a native C:\... script path is converted to /c/... on Windows (regressing the exit-127 failure), with a companion test asserting POSIX argv is passed through unchanged. The fix in cron/scheduler.py is otherwise left exactly as the maintainer requested.
|
Added the regression coverage as requested. Both new tests are in tests/cron/test_cron_no_agent.py:
cron/scheduler.py is otherwise unchanged from the fix. Both tests pass against the real code. PTAL. |
Native Win11 verification (monerostar)Host: Windows 11 build 26200, Python 3.11.15. Bash on PATH is Hermes-bundled Git/MSYS bash 5.3.9 ( Bug class is realPassing a native backslash path as argv to bash can collapse separators (POSIX-style escape handling), producing the classic missing-file path: That matches the PR description (exit 127 / mangled This PR’s conversionFocused unit tests on this branch: Live with Hermes bash + MSYS argv form outside Notes for maintainers
Verdict: LGTM for the Windows branch + tests. Happy to defer if maintainers prefer consolidating with #44350’s |
Summary
Fixes
.sh/.bashcron jobs failing on Windows with exit 127 ("No such file or directory"). The scheduler passed a Windows backslash path directly to git-bash, which treats\as an escape and collapses the path so the script is never found.Root cause
In
cron/scheduler.py,_run_job_script()didargv = [_bash, str(path)]. On Windowsstr(path)is a backslash path (C:\Users\...\x.sh); git-bash collapses it toC:Users...→ exit 127. The script never runs..pycron scripts are unaffected (run viasys.executable).Fix
Normalize the path to MSYS form (
/c/Users/...) whensys.platform == "win32", guarded so POSIX behavior is unchanged.Test plan
.shcron job failed exit 127 on Windows 10hermes cron run→ success, pushes to GitHubast.parseclean; no change to POSIX path handlingtests/cron/test_cron_no_agent.py:test_run_job_script_windows_argv_uses_msys_pathcaptures the argv passed tosubprocess.runand asserts a nativeC:\...script path is converted to/c/...(no backslashes);test_run_job_script_posix_argv_unchangedasserts the POSIX argv is passed through verbatim.Refs #62514
🤖 Generated with Claude Code