claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] ripgrep tool in FreeBSD constant failure for internal `Search`

Open lnxprof opened this issue 11 months ago • 4 comments

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Executive Summary

The Claude Code built-in Grep tool consistently fails on FreeBSD systems, returning zero results even when matches exist. This forces users to rely on bash grep commands as a workaround, reducing efficiency and requiring manual intervention.

Bug Description

The Grep tool, which is built on ripgrep, consistently returns "No matches found" or "Found 0 lines" on FreeBSD systems, even when the search pattern exists in the target files. The Glob tool functions correctly in the same environment, indicating this is specific to the Grep tool implementation.

What Should Happen?

Expected Behavior

The Grep tool should find and return all matching lines, similar to the bash grep command output.

Error Messages/Logs


Steps to Reproduce

Reproduction Steps

Test Case 1: Simple Pattern Search

  1. Create or identify a file with known content (e.g., /home/claudeuser/feature/WORKFLOW.md)
  2. Use Claude Code Grep tool to search for a known pattern:
    Grep pattern="Request" path="/home/claudeuser/feature/WORKFLOW.md"
    
  3. Observe: Returns "No matches found"
  4. Verify with bash grep:
    grep -n "Request" /home/claudeuser/feature/WORKFLOW.md
    
  5. Observe: Correctly finds 4 occurrences on lines 18, 43, 84, 96

Test Case 2: Code Search Example

  • Date First Observed: 2025-09-29
  • Search Pattern: "adjustFeedCosts" in PHP files
  • Grep Tool Result: Found 0 lines
  • Bash grep Result: Multiple matches found in Markup.php

Actual Behavior

The Grep tool consistently returns zero results regardless of:

  • Pattern complexity (simple strings or regex)
  • File type (markdown, PHP, text files)
  • Output mode (content, files_with_matches, count)
  • Search scope (single file or directory)

Impact

  1. Productivity Loss: Developers must remember to use bash workarounds instead of native tools
  2. Context Overhead: Using bash commands increases token usage in conversations
  3. Inconsistent Experience: Mixed tool reliability creates confusion
  4. Documentation Burden: Users must maintain separate notes about tool failures

Workaround

Users must use bash grep commands exclusively for content searching:

# Instead of Grep tool, use:
grep -n "pattern" /path/to/file
grep -r "pattern" /path/to/directory --include="*.php"
find /path -name "*.php" -exec grep -l "search_term" {} \;

Additional Evidence

Comparison Test Performed 2025-12-05

Glob Tool (WORKS):

  • Command: Glob pattern="*.md" path="/home/claudeuser/feature"
  • Result: Successfully found README.md and WORKFLOW.md

Grep Tool (FAILS):

  • Command: Grep pattern="Request" path="/home/claudeuser/feature/WORKFLOW.md"
  • Result: "No matches found"

Bash grep (WORKS):

  • Command: grep -n "Request" /home/claudeuser/feature/WORKFLOW.md
  • Result: Found 4 matches on lines 18, 43, 84, 96

Claude Model

None

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

1.0.04

Platform

Anthropic API

Operating System

Other

Terminal/Shell

Xterm

Additional Information

Technical Analysis

The issue appears to be specific to:

  1. The ripgrep binary or library interaction on FreeBSD
  2. Possible permission or file access differences between FreeBSD and Linux
  3. Potential character encoding or file reading implementation issues

The fact that Glob works but Grep fails suggests the issue is in the content reading/searching mechanism rather than file system access.

Suggested Fixes

  1. Test ripgrep binary directly on FreeBSD to isolate if it's a binary issue
  2. Check file reading permissions and methods used by the Grep tool
  3. Verify character encoding handling between the tool and FreeBSD file systems
  4. Consider implementing a fallback to system grep when ripgrep fails
  5. Add FreeBSD-specific testing to the Claude Code test suite

Environment Details

  • Operating System: FreeBSD 14.3-RELEASE-p5
  • Claude Code Version: Current as of 2025-12-05

lnxprof avatar Dec 05 '25 20:12 lnxprof

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/10673
  2. https://github.com/anthropics/claude-code/issues/7344
  3. https://github.com/anthropics/claude-code/issues/9462

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

github-actions[bot] avatar Dec 05 '25 20:12 github-actions[bot]

Found 3 possible duplicate issues:

  1. [BUG] FreeBSD not supported - bash commands hang indefinitely (v2.0.29) #10673
  2. File Search Returns No Results Despite Matching Content #7344
  3. [BUG] Bundled ripgrep fails on Raspberry Pi 5 due to jemalloc page size mismatch #9462

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

The first bug is not related as it is bash command hanging, this is relating to internal Search for claude. The second bug relates to Windows, and this specific issue is narrowed down to ripgrep on FreeBSD The third bug is also a Linux environment, not experiencing the issue here.

lnxprof avatar Dec 05 '25 20:12 lnxprof

Related https://github.com/anthropics/claude-code/issues/4741

lnxprof avatar Dec 05 '25 20:12 lnxprof

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Jan 05 '26 10:01 github-actions[bot]

Also experiencing this on FreeBSD 14.3. Using a SessionStart hook to symlink system ripgrep as a workaround. +1 for falling back to system rg when platform binary is missing.

mmenefee avatar Jan 28 '26 20:01 mmenefee

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Feb 28 '26 22:02 github-actions[bot]

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.

github-actions[bot] avatar Mar 09 '26 14:03 github-actions[bot]