fix(windows): put Git Bash coreutils on PATH for the non-login fallback - #64042
Merged
Conversation
#63955 made Hermes survive a broken `bash -l` (Ainz's `Directory \drivers\etc does not exist`) by falling back to non-login `bash -c`. But a non-login shell never sources /etc/profile, so it never gets `…\usr\bin` on PATH — and that dir holds every coreutil the file/terminal tools shell out to (cat, mktemp, mv, wc, head, stat, chmod, mkdir, find). Result: `write_file` returned bytes_written:0 with an EMPTY error (the failure text went to a missing binary's stderr) and terminal commands exited 127. The survive-broken-login-bash fix was only half-done: it stopped crashing but silently failed every write. Derive Git Bash's bin dirs (mingw64/bin, usr/bin, bin, …) from the resolved bash.exe and prepend them to the subprocess PATH on Windows, in /etc/profile precedence order so coreutils win over same-named System32 tools (find.exe, sort.exe) inside the shell. No-op off Windows and when a login snapshot is healthy (the snapshot re-exports the full PATH inside the shell), so this only bites on the broken-login fallback path. Adds _git_bash_bin_dirs() (derivation, cached) + _prepend_git_bash_dirs() (PATH merge), plus regression tests for PortableGit/MinGit layouts and the run-env injection ordering.
tonydwb
reviewed
Jul 14, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment
30 PRs reviewed (batch: 64044-63999). See aggregate summary at PR 64044.
Reviewed by Hermes Agent
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…s-nonlogin-coreutils-path fix(windows): put Git Bash coreutils on PATH for the non-login fallback
4 tasks
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…s-nonlogin-coreutils-path fix(windows): put Git Bash coreutils on PATH for the non-login fallback
prmartinow
pushed a commit
to prmartinow/hermes-agent
that referenced
this pull request
Aug 26, 2026
…s-nonlogin-coreutils-path fix(windows): put Git Bash coreutils on PATH for the non-login fallback
melon-xf
added a commit
to melon-xf/hermes-agent
that referenced
this pull request
Sep 3, 2026
…s-nonlogin-coreutils-path fix(windows): put Git Bash coreutils on PATH for the non-login fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Completes #63955. That PR made Hermes survive a broken Git Bash login shell (the classic Windows
Directory \drivers\etc does not existonbash -l) by falling back to a non-loginbash -c. But a non-login shell never sources/etc/profile, so it never gets…\Git\usr\binon PATH — and that directory holds every coreutil the file/terminal tools shell out to (cat,mktemp,mv,wc,head,stat,chmod,mkdir,find, …).Net effect on an affected box: the fallback stopped Hermes from crashing, but then silently failed every write:
The error string is empty because the failure text went to a missing binary's stderr, and terminal commands returned
exit 127(command not found). Sowrite_file→ terminalecho/catfallback both failed and nothing landed on disk.Fix
Derive Git Bash's binary dirs (
mingw64/bin,usr/bin,bin, …) from the already-resolvedbash.exeand prepend them to the subprocess PATH on Windows, in/etc/profileprecedence order so coreutils win over the same-named Windows System32 tools (find.exe,sort.exe) inside the shell._git_bash_bin_dirs()returns[]).Adds
_git_bash_bin_dirs()(derivation, cached) +_prepend_git_bash_dirs()(PATH merge), wired into_make_run_env.How to test
scripts/run_tests.sh tests/tools/test_local_env_windows_msys.py— 40 passed. NewTestGitBashCoreutilsOnPathcovers:<root>\bin\bash.exe) and MinGit (<root>\usr\bin\bash.exe) layouts[]off Windows / when bash is unresolvable_make_run_envprepends coreutils before System32; idempotent; POSIX no-opChecklist
[], PATH unchanged)