Skip to content

fix: resolve bash executable path for Windows test subprocess calls - #666

Open
Dakshkweera wants to merge 1 commit into
zilliztech:mainfrom
Dakshkweera:fix/bash-path-windows
Open

fix: resolve bash executable path for Windows test subprocess calls#666
Dakshkweera wants to merge 1 commit into
zilliztech:mainfrom
Dakshkweera:fix/bash-path-windows

Conversation

@Dakshkweera

Copy link
Copy Markdown

Closes #665

Problem

subprocess.run(["bash", ...]) only resolves bash on Windows when the calling shell already has Git's usr/bin on 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 raised FileNotFoundError: [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 from conftest.py) that:

  1. Tries shutil.which("bash") first (works on Linux/macOS/Git Bash where it's on PATH).
  2. Falls back to deriving Git's install root from the git executable (reliably on PATH via shutil.which("git")) and checks bin/bash.exe / usr/bin/bash.exe relative to it.
  3. Falls back to the bare "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:

  • 4 tests fixed, 0 regressions (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 .sh scripts they exercise call python3 internally, and Windows only ships python.exe (no python3 alias), 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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: subprocess.run(["bash", ...]) fails with WinError 2 outside Git Bash on Windows

1 participant