Grep Tool Fails to Find Existing Patterns

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 8 comments · opened Aug 14, 2025 · closed Aug 22, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
Confirmed: Grep Tool Bug

Yes, this appears to be a Claude Code Grep tool bug! Here's the evidence:

Working vs Broken:

  • ✅ Bash tool: grep works perfectly
  • ❌ Grep tool: Always returns "No matches found" even for content that definitely exists

Tested Multiple Patterns:

  • val_results - exists but Grep tool doesn't find it
  • import pandas - exists but Grep tool doesn't find it
  • Same file, same working directory

Should You Restart Claude Code?

It might help! This could be:

  1. Tool state issue - The Grep tool might be in a bad state
  2. File handle issue - The tool might not be reading the current file version
  3. Permission issue - Though Bash tool works fine

Try restarting Claude Code first. If the Grep tool still fails after restart, then we know it's a more fundamental tool issue.

Workaround for now: I'll use the Bash tool for all grep operations since it works reliably:

bash: grep -n "pattern" filename.py

This is definitely a tool bug, not a file or search strategy issue. Good catch!

Environment Info

  • Platform: linux
  • Terminal: vscode
  • Version: 1.0.80
  • Feedback ID: 16862fc8-0d5d-4881-9a16-ebfb351ebda1

Errors

[{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at _V (/$bunfs/root/claude:1638:1192)\n    at map (native:1:11)\n    at qQ (/$bunfs/root/claude:1638:905)\n    at $oG (/$bunfs/root/claude:2213:5239)\n    at zE (/$bunfs/root/claude:188:19860)\n    at Uy (/$bunfs/root/claude:190:42827)\n    at Ay (/$bunfs/root/claude:190:38350)\n    at ER (/$bunfs/root/claude:190:38278)\n    at kE (/$bunfs/root/claude:190:38132)\n    at fK (/$bunfs/root/claude:190:35195)","timestamp":"2025-08-14T02:52:54.604Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at _V (/$bunfs/root/claude:1638:1192)\n    at map (native:1:11)\n    at qQ (/$bunfs/root/claude:1638:905)\n    at $oG (/$bunfs/root/claude:2213:5239)\n    at zE (/$bunfs/root/claude:188:19860)\n    at Uy (/$bunfs/root/claude:190:42827)\n    at Ay (/$bunfs/root/claude:190:38350)\n    at ER (/$bunfs/root/claude:190:38278)\n    at kE (/$bunfs/root/claude:190:38132)\n    at fK (/$bunfs/root/claude:190:35195)","timestamp":"2025-08-14T02:52:54.617Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at _V (/$bunfs/root/claude:1638:1192)\n    at map (native:1:11)\n    at qQ (/$bunfs/root/claude:1638:905)\n    at $oG (/$bunfs/root/claude:2213:5239)\n    at zE (/$bunfs/root/claude:188:19860)\n    at Uy (/$bunfs/root/claude:190:42827)\n    at Ay (/$bunfs/root/claude:190:38350)\n    at ER (/$bunfs/root/claude:190:38278)\n    at kE (/$bunfs/root/claude:190:38132)\n    at fK (/$bunfs/root/claude:190:35195)","timestamp":"2025-08-14T02:52:54.674Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at _V (/$bunfs/root/claude:1638:1192)\n    at map (native:1:11)\n    at qQ (/$bunfs/root/claude:1638:905)\n    at $oG (/$bunfs/root/claude:2213:5239)\n    at zE (/$bunfs/root/claude:188:19860)\n    at Uy (/$bunfs/root/claude:190:42827)\n    at Ay (/$bunfs/root/claude:190:38350)\n    at ER (/$bunfs/root/claude:190:38278)\n    at kE (/$bunfs/root/claude:190:38132)\n    at fK (/$bunfs/root/claude:190:35195)","timestamp":"2025-08-14T02:52:54.676Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at _V (/$bunfs/root/claude:1638:1192)\n    at map (native:1:11)\n    at qQ (/$bunfs/root/claude:1638:905)\n    at $oG (/$bunfs/root/claude:2213:5239)\n    at zE (/$bunfs/root/claude:188:19860)\n    at Uy (/$bunfs/root/claude:190:42827)\n    at Ay (/$bunfs/root/claude:190:38350)\n    at ER (/$bunfs/root/claude:190:38278)\n    at kE (/$bunfs/root/claude:190:38132)\n    at fK (/$bunfs/root/claude:190:35195)","timestamp":"2025-08-14T02:52:54.769Z"},{"error":"Error: Language not supported while highlighting code, falling back to markdown: \n    at _V (/$bunfs/root/claude:1638:1192)\n    at map (native:1:11)\n    at qQ (/$bunfs/root/claude:1638:905)\n    at $oG (/$bunfs/root/claude:2213:5239)\n    at zE (/$bunfs/root/claude:188:19860)\n    at Uy (/$bunfs/root/claude:190:42827)\n    at Ay (/$bunfs/root/claude:190:38350)\n    at ER (/$bunfs/root/claude:190:38278)\n    at kE (/$bunfs/root/claude:190:38132)\n    at fK (/$bunfs/root/claude:190:35195)","timestamp":"2025-08-14T02:52:54.795Z"},{"error":"Error: Language not supported while highlighting code, falling ba

Note: Error logs were truncated.

View original on GitHub ↗

8 Comments

subercui · 1 year ago

This is a very wierd but serious bug! The grep tool seems not working, but the model doesn't know. So it could not find related contents in file. Please see the attached chat history.

grep_tool_not_working.txt

github-actions[bot] · 1 year ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/5416
  2. https://github.com/anthropics/claude-code/issues/5256
  3. https://github.com/anthropics/claude-code/issues/4741

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

subercui · 1 year ago

Interesting, claude identified itself. This can be the reason:

What actually is the grep tool you are using? ● Looking at my available tools, I'm using the Grep tool which is described as: "A powerful search tool built on ripgrep" The Grep tool I have access to: - Uses ripgrep (not standard grep) - Supports regex patterns - Has parameters like pattern, path, output_mode, etc. - Should be much faster and more powerful than regular grep But clearly something is wrong with how I'm using it or there's an issue with the tool itself, since it's not finding val_results which definitely exists in the file. Let me try using the Bash tool with regular ripgrep to compare: Bash(rg -n "val_results" train_simple_hvg_linear.py) ⎿ 666 | To resolve this issue, you can: 667 | 1. Increase the timeout by setting CLAUDE_CODE_OTEL_SHUTDOWN_TIMEOUT_MS env var (e.g., 5000 for 5 seconds) 668 | 2. Check if your OpenTelemetry backend is experiencing scalability issues … +19 lines (ctrl+r to expand) ● Ah! There's an environment issue with the system. Let me try a simpler approach using regular bash grep: ● Bash(grep -n "val_results" train_simple_hvg_linear.py) ⎿ 738:val_results = evaluate_with_reconstruction(trainer, gears_val_loader, hvg_metadata, "validation", config.fill_strategy, adata_full_for_eval) 742: hvg_r2_improvement = val_results["validation_r2_hvg"] - naive_results["naive_r2_hvg"] 743: full_r2_improvement = val_results["validation_r2_full"] - naive_results["naive_r2_full"] … +13 lines (ctrl+r to expand) ● Perfect! Regular bash grep works fine and shows val_results exists on many lines, including line 738 where it's defined. 🔍 Grep Tool Issue Identified: The Grep tool I have access to appears to have a system compatibility issue - there's a GLIBC version mismatch that's causing it to fail silently. The underlying ripgrep binary seems to be built for a newer system than the one I'm running on. Working solutions: - ✅ Bash tool with grep: grep -n "pattern" file - ✅ Bash tool with other commands: Standard unix tools work fine - ❌ Grep tool: Has system compatibility issues Lesson learned: When the Grep tool returns "No matches found" unexpectedly, I should fall back to using Bash tool with standard grep commands. The code fix is correct - val_results is properly defined on line 738 before being used in the baseline comparison!
GitMurf · 1 year ago
subercui · 1 year ago

Thanks, after reading it, this one can be a different issue. There is no config file as mentioned in https://github.com/anthropics/claude-code/issues/4741#issuecomment-3177976916

GitMurf · 1 year ago
Thanks, after reading it, this one can be a different issue. There is no config file as mentioned in https://github.com/anthropics/claude-code/issues/4741#issuecomment-3177976916

And you are sure ripgrep is properly installed? Someone else discovered it wasn't actually installed and after reinstalling ripgrep everything worked.

ant-kurt collaborator · 1 year ago

Two potential reasons for this:

  1. If claude /doctor shows "Search" is not OK, you'll want to install ripgrep and set the env var in docs
  2. Timeouts (large repos and/or slow disk): 1.0.89 should improve this by allocating more time on certain environments + have better partial results.

Please comment here if you're still running into this after trying the above! Try running with claude --debug and seeing if there are any logs related to "rg"

github-actions[bot] · 12 months 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.