Skip to content

search_code returns 0 matches when the indexed repo path contains a space (macOS) #679

Description

@doug306

Summary

search_code returns total_grep_matches: 0 for every pattern when the repository was indexed from a path that contains a space. The graph tools (search_graph, get_code_snippet, query_graph, get_architecture) work correctly on the same index — only search_code is affected. Re-indexing the identical tree from a path without a space makes search_code return correct results.

This looks like a sibling of #272 (search_code rejects paths containing &): the live grep / path handling doesn't appear to be quote/escape-safe for whitespace either, but here it fails silently (empty result, no error).

Environment

  • Version: codebase-memory-mcp 0.8.1 (release binary)
  • Platform: macOS x86_64 (Darwin)

Repro

# 1) Index a repo whose path contains a space:
codebase-memory-mcp cli index_repository '{"repo_path":"/Users/me/Dev Projects/myrepo"}'
# → {"status":"indexed","nodes":<N>,"edges":<M>, ...}   (indexing itself works fine)

# 2) search_code finds nothing — even for guaranteed-present strings:
codebase-memory-mcp cli search_code '{"project":"<slug>","pattern":"export function"}'
# → {"results":[],"raw_matches":[],"total_grep_matches":0,"total_results":0, ...}

# 3) But the graph tools work on the SAME index:
codebase-memory-mcp cli search_graph '{"project":"<slug>","name_pattern":"someFunc"}'
# → correct results (qualified_name, in_degree, file_path, ...)

# 4) Re-index the SAME tree via a no-space path (symlink) → search_code works:
ln -s "/Users/me/Dev Projects/myrepo" /tmp/myrepo
codebase-memory-mcp cli index_repository '{"repo_path":"/tmp/myrepo"}'
codebase-memory-mcp cli search_code '{"project":"<slug2>","pattern":"export function"}'
# → total_grep_matches: 100+   ✅

Reproduces identically via the cli interface and via MCP tools/call.

Impact

On macOS, user code commonly lives under paths with spaces (e.g. ~/Dev Projects/…, iCloud ~/Library/Mobile Documents/…). For those repos search_code is silently non-functional — it returns an empty result rather than erroring, which is easy to misread as a genuine "no matches."

Workaround

Index the repo via a symlink whose path contains no spaces.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority/normalStandard review queue; useful PR with ordinary maintainer urgency.ux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions