fix(cron): use POSIX paths for bash scripts on native Windows - #23405
fix(cron): use POSIX paths for bash scripts on native Windows#23405CalmProton wants to merge 1 commit into
Conversation
On native Windows, bash (Git Bash / MSYS2) interprets backslashes in path arguments as escape sequences, silently mangling them — a path like C:\Users\... becomes C:Users... and the script is never found, causing all no_agent cron jobs with .sh scripts to fail with exit code 127. Fix: use path.as_posix() on Windows to produce forward-slash paths (/c/Users/...) that MSYS2 bash understands natively. Gated behind os.name == 'nt' so non-Windows platforms continue to use str(path) with zero change in behavior. Closes NousResearch#23404
teknium1
left a comment
There was a problem hiding this comment.
Thanks for targeting the native-Windows cron-script failure. The current main path still passes str(path) directly to bash at cron/scheduler.py:2091, so the report remains actionable.
Problems
- The proposed
path.as_posix()call does not produce the/c/Users/...MSYS path stated in the PR. APureWindowsPathproducesC:/Users/...; the repository's established converter attools/environments/local.py:43-58performs the needed drive-prefix conversion to/c/.... - The diff has no regression test.
tests/cron/test_cron_no_agent.py:288-309verifies shell execution, but does not inspect the Windows argv passed to bash.
Suggested changes
- Reuse or extract the established Windows-to-MSYS conversion behavior for the cron bash argument.
- Add a host-independent argv-capture test for a drive-qualified Windows path, plus a POSIX no-conversion test.
Automated hermes-sweeper review.
| # path.as_posix() normalizes to POSIX forward-slash form | ||
| # (/c/Users/...) which MSYS2 bash understands natively. | ||
| # On non-Windows platforms, str(path) is already a valid POSIX path. | ||
| if os.name == "nt": |
There was a problem hiding this comment.
Path.as_posix() turns a drive-qualified Windows path into C:/..., not the /c/... MSYS form claimed here. Please reuse or extract the conversion behavior in tools/environments/local.py:_windows_to_msys_path, and add an argv-capture regression test for the exact /c/... result.
|
Reconciliation (2026-08-03): this PR's fix is covered by the open canonical #77393 — This branch's CI (last run on the May 10 base) fails only on pre-existing main breakage, none of it in this PR's files:
Recommendation: close as duplicate of #77393. The |
Summary
On native Windows with Git Bash,
.sh/.bashcron scripts always fail because bash interprets backslashes in the path argument as escape sequences, manglingC:\Users\...intoC:Users...(exit code 127, script not found).This PR gates a one-line fix behind
os.name == "nt": usepath.as_posix()to produce forward-slash paths (/c/Users/...) that MSYS2 bash understands natively. Non-Windows platforms are completely unaffected — they continue to usestr(path).How to Test
no_agent: trueand a.shscriptOr use the existing test suite:
The test
test_run_job_script_shell_script_runs_via_bashalready 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
Pre-submit checks
scripts/check-windows-footguns.py— zero footguns foundtests/cron/test_cron_no_agent.py— all 18 tests passRelated
Closes #23404