fix(workflows): resolve bash via absolute path on Windows (#1326)#1342
fix(workflows): resolve bash via absolute path on Windows (#1326)#1342atlas-architect wants to merge 2 commits intocoleam00:mainfrom
Conversation
) Fixes coleam00#1326. ## Problem On Windows, `child_process.execFile('bash', ...)` fails to use Git Bash even when Git Bash is first on PATH. Windows CreateProcess searches the System32 directory BEFORE consulting the PATH env var, so bare `'bash'` resolves to `C:\Windows\System32\bash.exe` — the WSL launcher. The WSL bash has two pathologies that break workflow bash nodes: 1. `${VAR}` expansion is broken when bash is invoked in `-c` mode via CreateProcess arg-passing. Variables emit as empty strings regardless of environment. 2. Path convention is `/mnt/c/...` rather than Git Bash's `/c/...`, so any absolute path substitutions (worktree paths, cwd, repo paths) mismatch expectations of downstream bash nodes. Symptom seen in A00 workflow: `precheck-worktree` node fails fast with TARGET empty, even though the token substitution correctly wrote TARGET=<path> into the script. ## Fix Add `resolveBashPath()` helper in `@archon/git/exec` that returns: - `process.env.ARCHON_BASH_PATH` if set (escape hatch for non-standard Git Bash installs, e.g. user-scope installer at `%LOCALAPPDATA%\Programs\Git\bin\bash.exe`) - `C:\Program Files\Git\bin\bash.exe` on Windows (Git Bash default) - `bash` on Linux/macOS (unchanged PATH behavior) Update the two `execFileAsync('bash', ...)` call sites in `dag-executor.ts` (bash node + loop node until-bash check) to call through `resolveBashPath()`. ## Verification Local smoke test on Windows 11 + Git Bash 2.47: ``` Resolved bash: C:\Program Files\Git\bin\bash.exe TARGET_FROM_PARENT=test-value-123 ← ${VAR} expansion works PATH_CONVENTION=/c/Dev/platform/Archon/... ← /c/ convention preserved ``` Before the patch (bare `'bash'`), same test returned: ``` Resolved bash: bash TARGET_FROM_PARENT= ← WSL bash dropped the variable PATH_CONVENTION=/mnt/c/Dev/... ← WSL mount convention ``` Type-check green across all 9 packages. ## Compatibility - Linux/macOS: no behavioral change (still resolves `bash` via PATH). - Windows with standard Git for Windows install: works out of the box. - Windows with user-scope Git install: override via ARCHON_BASH_PATH. - Docker containers (Linux): no change needed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @atlas-architect — thanks for opening this PR. This repository uses a PR template at
Could you fill those out (even briefly)? The template helps reviewers understand scope, risk, and rollback — it speeds up review significantly. If a section genuinely doesn't apply, just write "N/A" in it rather than leaving it blank. |
|
Thanks @Wirasm — totally fair catch, my bad on submitting against the template without filling it in properly. Just pushed an update with all 11 required sections filled per The fix itself is unchanged ( A few sections marked N/A where they genuinely don't apply (no related/depends-on issues, no migration). Open to iterating if anything still needs more detail. |
|
This is also targeting the wrong branch, it should target dev not main |
|
please reopen targeting the right branch before i review |
|
Reopened as #1470 targeting |
Fixes #1326.
Summary
child_process.execFile('bash', ...)resolves toC:\Windows\System32\bash.exe(WSL launcher) instead of Git Bash, because Windows CreateProcess searches System32 BEFORE PATH.${VAR}expansion in-cmode and uses/mnt/c/paths instead of Git Bash's/c/, breaking every workflow bash node whose token substitution depends on env vars or path strings. Archon CLI on Windows fails with confusing "empty variable" symptoms.resolveBashPath()helper in@archon/git/execreturnsARCHON_BASH_PATHenv override →C:\Program Files\Git\bin\bash.exeWindows default →bash(Linux/macOS PATH unchanged). BothexecFileAsync('bash', ...)sites indag-executor.ts(bash node + loop node until-bash check) call through the helper.UX Journey
Before
After
Architecture Diagram
Before
After
Connection inventory:
'bash'resolveBashPath)Label Snapshot
risk: lowsize: Scoregit:exec(helper) +workflows:executor(call sites)Change Metadata
bugcoreLinked Issue
bashresolves to WSL launcher (System32\bash.exe) — $VAR expansion broken in-cmode #1326Validation Evidence (required)
$ bun run type-check # Output: 9 packages green (no TypeScript errors)bun run lint,bun run format:check,bun run testnot run by submitter — fix is surgical (1 helper function + 2 call-site updates). Happy to run on request, or rely on CI.Security Impact (required)
process.env.ARCHON_BASH_PATHif set; no file system writes — only spawns the existing bash binary at a more deterministic path)Compatibility / Migration
bashvia PATH)ARCHON_BASH_PATHis a NEW optional env var; defaults work for standard Git for Windows installs.Human Verification (required)
What was personally validated beyond CI:
Verified scenarios:
${VAR}expansion works,/c/path convention preserved'bash') → confirmed empty${VAR}+/mnt/c/pathsEdge cases checked:
%LOCALAPPDATA%\Programs\Git\...) → flagged asARCHON_BASH_PATHuse case'bash') → unchanged PATH behaviorWhat was NOT verified:
'bash'on non-Windows)Smoke test output (after patch):
Before the patch (bare
'bash'):Side Effects / Blast Radius (required)
bash:nodes when CLI runs on Windows. Loop nodes withuntil-bashconditions.bash.exe(higher on PATH) will now resolve to Git Bash specifically. Was non-deterministic before.ARCHON_BASH_PATHis the override.Rollback Plan (required)
git revert <commit-sha>— single commit, no migration. Reverting reinstates bare'bash'resolution behavior.ARCHON_BASH_PATH=bashenv var would partially undo the fix at runtime without code change.${VAR},/mnt/c/paths). Linux/macOS unaffected.Risks and Mitigations
C:\Program Files\Git\bin\bash.exemay not exist on user-scope installer or Windows Server with no Git for Windows.ARCHON_BASH_PATHenv var provides clean override. Helper falls through to PATH search if hardcoded path doesn't exist (preserves current behavior in that edge case). Open to walking PATH manually for the first non-System32bash.exeif reviewer prefers a fancier heuristic — env-var-plus-default kept the fix surgical.execFileAsync('bash', ...)site without going throughresolveBashPath().@archon/git/execfor discoverability. Could add ESLint rule banning bare'bash'literal in future hardening pass if recurrence is observed.Notes for reviewers
The Windows default (
C:\Program Files\Git\bin\bash.exe) is the standard install location for Git for Windows. If you run into edge cases on Windows Server or custom Git installs,ARCHON_BASH_PATHgives a clean override without requiring a new patch.Happy to iterate on the detection heuristic if you'd prefer something fancier (e.g. walking PATH manually to find the first non-System32
bash.exe), but the env-var-plus-sensible-default approach keeps the fix surgical and overridable.