You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After PR #310 ("add Windows support for code search via PowerShell"), search_code is callable without errors but always returns 0 results on Windows. The underlying PowerShell Select-String command executes but fails to match any files, with the error 系统找不到指定的路径 (system cannot find the path specified). Manual reproduction of the same PowerShell pipeline works correctly, pointing to a path resolution issue in the _popen child-process context.
Steps to Reproduce
Index a project with mode=full (confirmed 5,853 nodes via index_status)
The write_scoped_filelist function writes indexed file paths to the temp filelist. Per PR #310, these paths now use forward slashes (e.g., C:/projects/edit_center/backend/services/capsule_service.py).
Hypothesis: When _popen/CreateProcess spawns the PowerShell child process, the working directory or path resolution context differs from the interactive shell. This causes Select-String -LiteralPath to fail resolving the forward-slash paths from the filelist, even though the same paths work in an interactive PowerShell session.
Alternative possibility: The temp filelist itself may not be flushed/closed before the PowerShell child process reads it, causing an empty filelist to be piped into Select-String.
Impact
search_code is effectively non-functional on Windows post-#310. Users see silent empty results with no error surfaced through the MCP/CLI response — only visible in stderr. search_graph (BM25) works correctly and serves as a workaround.
Suggested Fixes
Flush and close the filelist before spawning PowerShell — ensure fclose() on the filelist before _popen().
Use absolute paths with backslashes in the filelist — Windows Select-String handles both, but backslashes are canonical and avoid potential resolution issues in child processes.
Add -NoProfile -NonInteractive to the PowerShell invocation to avoid profile-loading side effects.
Capture and surface stderr from the PowerShell child process so failures are visible to the caller instead of silently returning 0 results.
Environment Details
OS: Windows 11 25H2 (OS Build 26200+)
Shell: PowerShell 5.1.22621 (also tested with cmd.exe — same result)
Bug:
search_codereturns 0 results on Windows —Select-Stringvia_popenfails with "系统找不到指定的路径"Repository: DeusData/codebase-memory-mcp
Environment: Windows 11 25H2, PowerShell 5.1, codebase-memory-mcp binary (post-#310 merge, PowerShell
Select-Stringpath)Index mode:
full(5,853 nodes / 10,978 edges)Project: Python backend + TypeScript frontend (~200 files)
Summary
After PR #310 ("add Windows support for code search via PowerShell"),
search_codeis callable without errors but always returns 0 results on Windows. The underlying PowerShellSelect-Stringcommand executes but fails to match any files, with the error系统找不到指定的路径(system cannot find the path specified). Manual reproduction of the same PowerShell pipeline works correctly, pointing to a path resolution issue in the_popenchild-process context.Steps to Reproduce
mode=full(confirmed 5,853 nodes viaindex_status)search_codevia MCP:{ "pattern": "def create_capsule", "project": "C-projects-edit_center", "limit": 10, "mode": "compact" }{"results":[], "total_grep_matches": 0, "total_results": 0}系统找不到指定的路径Manual Verification (PowerShell Works)
The exact same PowerShell pipeline, when run manually, works correctly:
✅ This finds matches. The
Select-Stringinvocation itself is correct.Root Cause Analysis
The issue is in
build_grep_cmd()atsrc/mcp/mcp.c. The Windows branch (post-#310) constructs:The
write_scoped_filelistfunction writes indexed file paths to the temp filelist. Per PR #310, these paths now use forward slashes (e.g.,C:/projects/edit_center/backend/services/capsule_service.py).Hypothesis: When
_popen/CreateProcessspawns the PowerShell child process, the working directory or path resolution context differs from the interactive shell. This causesSelect-String -LiteralPathto fail resolving the forward-slash paths from the filelist, even though the same paths work in an interactive PowerShell session.Alternative possibility: The temp filelist itself may not be flushed/closed before the PowerShell child process reads it, causing an empty filelist to be piped into
Select-String.Impact
search_codeis effectively non-functional on Windows post-#310. Users see silent empty results with no error surfaced through the MCP/CLI response — only visible in stderr.search_graph(BM25) works correctly and serves as a workaround.Suggested Fixes
fclose()on the filelist before_popen().Select-Stringhandles both, but backslashes are canonical and avoid potential resolution issues in child processes.-NoProfile -NonInteractiveto the PowerShell invocation to avoid profile-loading side effects.Environment Details
C-projects-edit_centersearch_codetool and CLIsearch_codesubcommandRelated Issues/PRs
Select-Stringapproach (merged 2026-05-10)search_codereturns "search failed: temp file" on Windows 11 in Powershell #196 — Original/tmphardcode bug (fixed by feat(mcp): add Windows support for code search via PowerShell #310)/tmpreport (closed as duplicate)rgmissing path arg)