Repository navigation
search_code returns empty on Windows: server shells out to hardcoded /bin/bash + GNU grep #422
Description
Summary
On Windows, search_code always returns 0 results (total_grep_matches: 0, raw_match_count: 0) for every query — even patterns that definitely exist in the indexed project. The graph-backed tools (search_graph, query_graph, get_architecture, index_status, list_projects, …) all work correctly, so the index itself is fine — only the text-search path is broken. The failure is silent: an empty result is indistinguishable from "no matches."
Environment
- codebase-memory-mcp 0.6.1 (npm global, Windows x64 binary
bin/codebase-memory-mcp.exe) - OS: Windows 10 Pro (19045)
- Launched as a stdio MCP server by a Windows GUI host (Claude Code), inheriting the host process environment.
Reproduction
index_repositoryon a Windows repo — succeeds;index_statusreports nodes/edgesready.- Call
search_codewith any pattern known to exist (e.g.class, or a unique identifier in the repo). - Every call returns
{"files":[],"total_grep_matches":0,"raw_match_count":0, ...}. search_graph/query_graphon the same project return correct results — confirming the index is good and only the grep/text path is broken.
Root cause
The text-search path shells out to a Unix shell pipeline with a hardcoded absolute path. Strings extracted from the shipped Windows binary show the command templates:
/bin/bash
grep -rn %s --include='%s' -f '%s' '%s' 2>/dev/null
xargs grep -n %s --include='%s' -f '%s' < '%s' 2>/dev/null
On Windows:
/bin/bashdoes not exist (it's an absolute Unix path, not resolved viaPATH, so no amount of PATH configuration fixes it).grep/xargsare not present by default.
So the spawned process fails, and because the pipeline ends in 2>/dev/null the empty output is interpreted as "no matches" rather than surfaced as an error. This affects all Windows users.
Impact
search_codeis entirely non-functional on Windows.- The empty-vs-unavailable ambiguity means agents/users silently get wrong (empty) answers and may conclude code doesn't exist when it does.
Suggested fixes (any one)
- In-process native search (preferred). The project ships as a single static Rust binary ("zero dependencies"); using the
grep/grep-searcher+ignore/globsetcrates (ripgrep's libraries) in-process removes the externalbash/grep/xargsdependency entirely, is cross-platform, and is faster. - Invoke ripgrep directly (no shell). Spawn
rgwith--glob(instead ofgrep --include+xargsunderbash); avoids the shell and the/bin/bashassumption. Bundlergor document it as a dependency. - At minimum, fail loudly. Detect when the search backend can't run and return an explicit error to the client instead of an empty result set.
Current workaround for Windows users
Run the Linux build of the server inside WSL (e.g. configure the MCP command as wsl -e codebase-memory-mcp), where /bin/bash, grep, and xargs exist natively; index via /mnt/c/... paths. The Windows-native binary's search_code cannot work without a Unix shell environment.
Activity
arwinscholte commentedon Jun 7, 2026
Closing as a likely duplicate of #348 (tracked under the Windows umbrella #394), which is marked fixed in v0.7.0.
Context: I filed this against v0.6.1 without checking for a newer release — my mistake. On v0.6.1 the
search_codepath shells out to/bin/bash -c "… grep -rn --include=… | xargs grep … 2>/dev/null", so on Windows (no/bin/bash) it silently returns 0 results. That's the same symptom as #348 ("search_code 0 results on Windows").I've since upgraded to v0.7.0 and inspected the binary — the Windows search path now uses PowerShell
Select-String(the PR #325 / #348 work) rather than/bin/bash, so the specific mechanism reported here no longer applies. Closing on that basis; will reopen only ifsearch_codestill returns empty after retesting on v0.7.0.Thanks for the umbrella tracker — apologies for the duplicate noise.