fix: resolve bash executable path for Windows test subprocess calls - #666
Open
Dakshkweera wants to merge 1 commit into
Open
fix: resolve bash executable path for Windows test subprocess calls#666Dakshkweera wants to merge 1 commit into
Dakshkweera wants to merge 1 commit into
Conversation
subprocess.run(["bash", ...]) only resolves on Windows when the
calling shell already has Git's usr/bin on PATH (i.e. inside Git
Bash itself). A plain PowerShell/cmd session doesn't, so the bare
string raised FileNotFoundError (WinError 2).
Resolve the executable via shutil.which("bash") first, falling back
to deriving Git's install root from the git executable (reliably on
PATH) and checking bin/bash.exe and usr/bin/bash.exe relative to it.
Fixes zilliztech#665
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.
Closes #665
Problem
subprocess.run(["bash", ...])only resolvesbashon Windows when the calling shell already has Git'susr/binon PATH (i.e. inside a Git Bash session itself). A plain PowerShell/cmd session doesn't have it on PATH at all, so the bare string raisedFileNotFoundError: [WinError 2].Fix
Added a small
_resolve_bash()helper (duplicated in each affected test file, since this pytest config's import mode doesn't reliably support cross-file imports fromconftest.py) that:shutil.which("bash")first (works on Linux/macOS/Git Bash where it's on PATH).gitexecutable (reliably on PATH viashutil.which("git")) and checksbin/bash.exe/usr/bin/bash.exerelative to it."bash"string if neither resolves, preserving current behavior everywhere else.Verified
Tested on Windows 11 in a plain PowerShell session (not Git Bash) — the actual repro conditions from #665. Diffed the full test suite's failure list before/after:
test_claude_hook_memsearch_disable_exits_before_writing_memory,test_claude_session_start_does_not_create_journal,test_claude_session_start_falls_back_for_older_cli,test_session_start_shows_skill_candidate_hint)Note on scope
Some other tests in these same files (
test_codex_parse_rollout.py,test_codex_stop_hook_utf8.py) still fail on Windows for an unrelated reason: the.shscripts they exercise callpython3internally, and Windows only shipspython.exe(nopython3alias), so it falls through to the Microsoft Store app-execution-alias stub. That's a separate, pre-existing issue affecting ~33 files across the plugins — out of scope for this PR, happy to file it separately if useful.