Skip to content

fix(shell): keep Git Bash coreutils on PATH#108136

Merged
steipete merged 4 commits into
openclaw:mainfrom
ooiuuii:fix/windows-bash-git-coreutils-path-clean
Jul 17, 2026
Merged

fix(shell): keep Git Bash coreutils on PATH#108136
steipete merged 4 commits into
openclaw:mainfrom
ooiuuii:fix/windows-bash-git-coreutils-path-clean

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Closes #108133

What Problem This Solves

Windows users could launch Git Bash through OpenClaw but still get command-not-found failures for Git-for-Windows tools when Git\usr\bin was absent from the parent PATH. Duplicate case variants such as PATH and Path could also make Node pass a different value than the one OpenClaw augmented.

This affected the Bash tool and !command config values that rely on Git Bash tools such as cat, sed, grep, and cygpath.

Why This Change Was Made

The fix builds one canonical Windows PATH before spawning. For a verified Git-for-Windows Bash, it prepends the matching usr\bin directory. Verification requires the sibling cmd\git.exe marker, so unrelated MSYS2 or custom Bash installations keep their own toolchain layout. The lookup is bounded and process-stable.

Both Bash execution paths now share this environment:

  • the model-facing Bash tool
  • !command config resolution

Regular Windows PowerShell execution is unchanged.

User Impact

Git-for-Windows users can run Bash-backed OpenClaw commands without adding Git\usr\bin to their global PATH. Custom MSYS2 users are unaffected.

Evidence

Focused local proof:

  • node scripts/run-vitest.mjs src/agents/shell-utils.test.ts src/agents/sessions/tools/bash.test.ts src/agents/sessions/windows-git-bash-path.test.ts -> 43 passed, 1 skipped; two Windows-only integration tests skipped on macOS
  • targeted type-aware oxlint -> passed
  • targeted oxfmt --check -> passed
  • git diff --check -> passed
  • branch autoreview -> clean, no accepted/actionable findings

Native Windows Testbox proof:

  • Windows Testbox Probe on exact head 9c26baf3a34e -> passed
  • checkout log confirms full head 9c26baf3a34eb7cc4435f4cdb53447bb7be3c965
  • src/agents/sessions/windows-git-bash-path.test.ts -> 2 passed, exercising the Bash tool and !command against Git-for-Windows cygpath
  • complete Windows-native CI command -> 8 Vitest shards passed

Coverage also includes standard and portable Git-for-Windows roots, unrelated MSYS2 roots, case-insensitive PATH-key deduplication, and the actual child-process environment.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jul 15, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 15, 2026, 10:55 PM ET / July 16, 2026, 02:55 UTC.

Summary
The PR adds a Git-for-Windows-specific Bash environment that prepends the installation’s usr\bin directory for Bash tool and !command execution.

PR surface: Source +59, Tests +92. Total +151 across 4 files.

Reproducibility: yes. source-reproducible: use a Windows-style environment whose inherited key is Path, let getShellEnv() add PATH, and observe that Node passes the unchanged uppercase entry to the Bash child. No real current-head Windows run is attached.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: src/agents/sessions/resolve-config-value.ts, serialized state: src/agents/sessions/tools/bash.ts, unknown-data-model-change: src/agents/sessions/tools/bash.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #108133
Summary: This PR is the candidate fix for the paired open issue, but its current head does not yet reliably resolve the reported Windows behavior.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Canonicalize case-insensitive PATH keys and add a regression that verifies the environment received by a spawned child process.
  • Attach redacted Windows terminal proof for both Bash tool execution and !command, including confirmation that custom MSYS2 behavior is unchanged.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR supplies unit tests, formatting, and autoreview output but no after-fix Windows run showing cat or similar coreutils through an OpenClaw Bash tool and !command; add redacted terminal output or a recording, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Risk before merge

  • [P1] The helper prepends Git’s usr\bin for every verified Git Bash child, changing command precedence for existing Windows setups; no live upgrade-path run demonstrates that intended Git tools win without disturbing custom Bash or MSYS2 workflows.

Maintainer options:

  1. Normalize and prove Windows PATH handling (recommended)
    Before merge, remove duplicate case-insensitive PATH variants, test the actual child-process environment, and attach a redacted Windows run covering Git Bash coreutils and the custom-MSYS2 exclusion.

Next step before merge

  • [P1] The contributor should correct the PATH-key handling and provide real Windows proof; automated repair cannot satisfy the external real-environment proof gate.

Security
Cleared: The patch adds no dependency, downloaded code, secret handling, permission, or new authorization surface; the remaining concern is functional PATH compatibility.

Review findings

  • [P1] Update the PATH key Node passes to Windows children — src/agents/shell-utils.ts:361
Review details

Best possible solution:

Keep the Bash-specific boundary, but collapse all case-insensitive PATH variants into one canonical property before prepending the verified Git usr\bin, cache the process-stable shell facts, and prove both Git Bash and unaffected custom MSYS2 behavior on Windows.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: use a Windows-style environment whose inherited key is Path, let getShellEnv() add PATH, and observe that Node passes the unchanged uppercase entry to the Bash child. No real current-head Windows run is attached.

Is this the best way to solve the issue?

No. A Bash-specific environment is the right boundary, but the implementation must canonicalize Windows PATH casing and validate the environment received by an actual child process.

Full review comments:

  • [P1] Update the PATH key Node passes to Windows children — src/agents/shell-utils.ts:361
    getShellEnv() spreads the inherited Windows Path key and then adds uppercase PATH, but this line updates the first case-insensitive match (Path). Node lexicographically passes only uppercase PATH when both exist, so usr\bin is still absent from the spawned Bash environment on typical Windows installs. Remove duplicate casing variants and set one canonical key; cover this with an actual child-process assertion rather than inspecting the returned object.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7f9d519fcb0d.

Label changes

Label changes:

  • add P1: The linked bug breaks Bash-backed agent commands and configured shell commands for affected Windows users.
  • add merge-risk: 🚨 compatibility: The PR changes executable resolution order for all verified Git-for-Windows Bash children, while the current implementation mishandles common Windows PATH casing and lacks live upgrade proof.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies unit tests, formatting, and autoreview output but no after-fix Windows run showing cat or similar coreutils through an OpenClaw Bash tool and !command; add redacted terminal output or a recording, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.

Label justifications:

  • P1: The linked bug breaks Bash-backed agent commands and configured shell commands for affected Windows users.
  • merge-risk: 🚨 compatibility: The PR changes executable resolution order for all verified Git-for-Windows Bash children, while the current implementation mishandles common Windows PATH casing and lacks live upgrade proof.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR supplies unit tests, formatting, and autoreview output but no after-fix Windows run showing cat or similar coreutils through an OpenClaw Bash tool and !command; add redacted terminal output or a recording, then update the PR body to trigger review or ask a maintainer for @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +59, Tests +92. Total +151 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 64 5 +59
Tests 1 98 6 +92
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 162 11 +151

What I checked:

  • Current environment construction: Current main builds shell environments by spreading process.env and then assigning an uppercase PATH, which can produce both Path and PATH properties on Windows. (src/agents/shell-utils.ts:308, 7f9d519fcb0d)
  • Blocking PATH-key selection: The proposed helper updates the first case-insensitive PATH property; when the spread environment contains Path before the added uppercase PATH, it modifies Path while leaving the uppercase entry unchanged. (src/agents/shell-utils.ts:361, ed5b434fb8a9)
  • Windows child-process contract: Node documents that Windows environment keys are case-insensitive, but child-process spawning lexicographically selects only the first matching key; with both variants present, uppercase PATH is passed and the modified Path value is discarded.
  • Regression-test gap: The new tests inspect the same first matching property in a mocked environment rather than spawning a Windows child with both Path and PATH, so they do not exercise Node’s key-selection behavior. (src/agents/shell-utils.test.ts:214, ed5b434fb8a9)
  • Affected execution paths: The new environment is passed through both local Bash tool execution and synchronous configured-shell command evaluation, so the defect affects both user paths named by the PR. (src/agents/sessions/tools/bash.ts:61, ed5b434fb8a9)
  • Shell feature history: File history ties Windows shell selection and fallback behavior to fa525bf212807735c0a0fb926e416ac55f0dbe99 and b33bd6aaeb90fe220cbbd19538146814e2afd8fd, with recent shared shell-environment work in ea9f17256a4b2d1acb41392167f4852dfa491038. (src/agents/shell-utils.ts:1, fa525bf21280)

Likely related people:

  • steipete: The shell utility history shows repeated commits and merges for Windows shell selection, fallback behavior, and shared shell-environment handling. (role: recent shell-runtime merger; confidence: high; commits: fa525bf21280, b33bd6aaeb90, 7b414d8c0b9f; files: src/agents/shell-utils.ts, src/agents/shell-utils.test.ts)
  • myfunc: Authored the merged Windows PowerShell/system-utility behavior that forms part of the current cross-platform shell contract. (role: Windows shell behavior contributor; confidence: medium; commits: b33bd6aaeb90; files: src/agents/shell-utils.ts, src/agents/shell-utils.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete force-pushed the fix/windows-bash-git-coreutils-path-clean branch from ed5b434 to 85ab133 Compare July 17, 2026 10:58
@steipete
steipete force-pushed the fix/windows-bash-git-coreutils-path-clean branch from 85ab133 to bd40eb9 Compare July 17, 2026 11:03
@steipete
steipete merged commit ecfcaa0 into openclaw:main Jul 17, 2026
121 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
* fix(windows): expose Git Bash coreutils to commands

Co-authored-by: luyifan <[email protected]>

* test(windows): inject duplicate PATH variants

* test(windows): run Git Bash integration in CI

* refactor(windows): keep shell env helper private

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows Git Bash commands can miss bundled coreutils

2 participants