Description
Several tests shell out to .sh hook scripts via subprocess.run(["bash", ...]). This works when pytest runs inside a Git Bash session, but fails with FileNotFoundError: [WinError 2] The system cannot find the file specified when run from a standard PowerShell or cmd.exe terminal — the more common setup for Windows contributors and CI runners.
Root cause: Git for Windows adds Git\cmd and Git\mingw64\bin to the system PATH, but bash.exe actually lives in Git\usr\bin, which is only added to PATH by Git Bash's own launcher — not the system-wide PATH. So subprocess.run(["bash", ...]) can't resolve bash outside a Git Bash shell.
Affected files:
tests/test_claude_hooks.py (10 call sites)
tests/test_codex_parse_rollout.py
tests/test_claude_parse_transcript.py
tests/test_codex_stop_hook_utf8.py
Expected: Tests should pass regardless of which Windows shell pytest is invoked from.
Proposed fix: Add a shared helper (e.g. new tests/conftest.py) resolving the bash executable via shutil.which("bash"), falling back to the literal "bash", and use that resolved path in all subprocess.run calls instead of the hardcoded string. Happy to submit a PR for this.
Steps to reproduce
- On Windows, with Git for Windows installed normally (not via WSL2)
- Open a plain PowerShell or cmd.exe terminal (not Git Bash)
- Run: git clone https://github.com/zilliztech/memsearch.git
cd memsearch
uv sync --all-extras
uv run python -m pytest tests/test_claude_hooks.py -x
Error output / logs
FileNotFoundError: [WinError 2] The system cannot find the file specified
tests\test_claude_hooks.py:42: in test_claude_hook_memsearch_disable_exits_before_writing_memory
result = subprocess.run(
C:\Program Files\Python313\Lib\subprocess.py:554: in run
with Popen(*popenargs, **kwargs) as process:
C:\Program Files\Python313\Lib\subprocess.py:1036: in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
C:\Program Files\Python313\Lib\subprocess.py:1548: in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
memsearch version
memsearch, version 0.4.17
Operating system
Windows
Python version
Python 3.13.1
Description
Several tests shell out to
.shhook scripts viasubprocess.run(["bash", ...]). This works when pytest runs inside a Git Bash session, but fails withFileNotFoundError: [WinError 2] The system cannot find the file specifiedwhen run from a standard PowerShell or cmd.exe terminal — the more common setup for Windows contributors and CI runners.Root cause: Git for Windows adds
Git\cmdandGit\mingw64\binto the system PATH, butbash.exeactually lives inGit\usr\bin, which is only added to PATH by Git Bash's own launcher — not the system-wide PATH. Sosubprocess.run(["bash", ...])can't resolvebashoutside a Git Bash shell.Affected files:
tests/test_claude_hooks.py(10 call sites)tests/test_codex_parse_rollout.pytests/test_claude_parse_transcript.pytests/test_codex_stop_hook_utf8.pyExpected: Tests should pass regardless of which Windows shell pytest is invoked from.
Proposed fix: Add a shared helper (e.g. new
tests/conftest.py) resolving the bash executable viashutil.which("bash"), falling back to the literal"bash", and use that resolved path in allsubprocess.runcalls instead of the hardcoded string. Happy to submit a PR for this.Steps to reproduce
cd memsearch
uv sync --all-extras
uv run python -m pytest tests/test_claude_hooks.py -x
Error output / logs
memsearch version
memsearch, version 0.4.17
Operating system
Windows
Python version
Python 3.13.1