[BUG] Vendored ripgrep won't launch if Claude Code is installed into a directory with a space in the path

Status Fixed / completed
Maintainer reply ✓ Yes — rboyce-ant
Activity 9 comments · opened Apr 9, 2025 · closed May 14, 2025
💡 Likely answer: A maintainer (rboyce-ant, contributor) responded on this thread — see the highlighted reply below.

Environment

  • Platform (select one):
  • [X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 0.2.66
  • Operating System: macOS Sequoia 15.1.1
  • Terminal: iTerm2, Terminal App

Bug Description

The Search step always returns no results even for trivial patterns. This makes Claude use a lot more resources to read files looking for things.

Steps to Reproduce

  1. Create a new "project" directory, named foo.
  2. cd foo
  3. Create a new file called womble.py with the contents:
def cabbage():
    return "cabbage"
  1. Run claude --verbose --debug --mcp-debug
  2. Tell Claude to "search for the "cabbage" function using only the search feature"

Expected Behavior

I expected the "Search" tool to be invoked and for it to find the function with that alone.

Actual Behavior

The Search tool finds nothing. Telling Claude to read the file and look for the function shows it can do that though.

Additional Context

<img width="1169" alt="Image" src="https://github.com/user-attachments/assets/bb9a0a41-86a1-4990-85bd-91483c58c2ef" />

View original on GitHub ↗

9 Comments

LasseRafn · 1 year ago

Honestly they should try getting embeddings for files and searching by those as well. I've gotten great results and cost to get embeddings even for 1000 files is negligible.

millimoose · 1 year ago

Kind of neither here nor there, quite likely live Search would be good enough if there wasn't something categorically wrong with it that makes it not work (on my machine?) Frankly the quoted "undefined" above bothers me, is it possible it's trying to tell the tool to search all files but accidentally stringifies the JS undefined resulting in a path that doesn't exist?

rboyce-ant contributor · 1 year ago

For some reason, Claude is passing the string "undefined" as the path argument. Do you have something in your CLAUDE.md or elsewhere in the session that might be causing it to think that it needs to do that? I'm only able to reproduce this behavior if I tell Claude "be sure to pass "undefined" as the "path" argument to Search tool"

millimoose · 1 year ago

@rboyce-ant the screenie in the issue comes from a new session in a new directory with just womble.py in it; same behaviour happens in my actual work project, again without a CLAUDE.md

If it's localized to anything, it seems to be my system rather than the project. Where does Claude store that sort of state? I could try wiping that to a clean slate.

millimoose · 1 year ago

I nuked ~/.claude and ~/.claude.json, uninstalled the claude code package, deleted leftovers in node's lib/, reinstalled, no dice. Tried to cluebat Claude into not passing a string "undefined" to the search tool, no dice.

<img width="860" alt="Image" src="https://github.com/user-attachments/assets/a48391ee-23e6-46fc-a27d-74a24fd6c9b2" />

millimoose · 1 year ago

Further weirdness that could be related is that in my main project, sometimes a file glob gets passed as the "pattern" and that works?! Even though it seems that's what the "include" argument should be doing. Kind of at a loss at how to provide more useful diagnostic information here, since the inner workings of this are so opaque.

<img width="1348" alt="Image" src="https://github.com/user-attachments/assets/29bd9288-a98c-4152-b66c-3f8ca5e1daef" />

millimoose · 1 year ago

wait I think I got it

after running cli.js through prettier and making a wild guess that you're using debug
for logging, I got the following output:

claude:ripgrep ripgrep called: /Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg '/Users/david/Repos/_vendelux/foo' [ '--files', '--hidden' ] +0ms
  claude:ripgrep ripgrep error: Error: spawn /Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg ENOENT     at ChildProcess._handle.onexit (node:internal/child_process:285:19)     at onErrorNT (node:internal/child_process:483:16)     at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg', path: '/Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg', spawnargs: [ '--files', '--hidden', '/Users/david/Repos/_vendelux/foo' ], cmd: '/Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg --files --hidden /Users/david/Repos/_vendelux/foo' } +1ms
  claude:ripgrep ripgrep called: /Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg '/Users/david/Repos/_vendelux/foo' [ '-Uli', '--multiline-dotall', 'cabbage' ] +2s
  claude:ripgrep ripgrep error: Error: spawn /Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg ENOENT     at ChildProcess._handle.onexit (node:internal/child_process:285:19)     at onErrorNT (node:internal/child_process:483:16)     at process.processTicksAndRejections (node:internal/process/task_queues:90:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg', path: '/Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg', spawnargs: [ '-Uli', '--multiline-dotall', 'cabbage', '/Users/david/Repos/_vendelux/foo' ], cmd: '/Users/david/Library/Application%20Support/fnm/node-versions/v22.14.0/installation/lib/node_modules/@anthropic-ai/claude-code/vendor/ripgrep/arm64-darwin/rg -Uli --multiline-dotall cabbage /Users/david/Repos/_vendelux/foo' } +4ms
No occurrences of "cabbage" found in the codebase.

Seems like the space in Application Support is getting escaped as %20, except that this isn't a URL, so trying to call ripgrep just fails completely.

I would, you know, maybe not use import.meta.url to get paths into a Unix filesystem and then try to pass them to an API that does not, in fact, support URLs. Claude should also perhaps complain a bit more vocally about failing to spawn tools. This bug probably cost me a few bucks because Claude had to search for everything the hard way lol

Workaround is installing an external ripgrep.

ant-kurt collaborator · 1 year ago

Should be resolved in v0.2.114

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.