No Results Found¶
If ripgrep returns zero results when you expect matches, try these troubleshooting steps:
Quick Checklist - Start Here
- Check files being searched:
rg --files(are your expected files listed?) - Bypass ignore files: Try
rg -u patternorrg -uu pattern - Include hidden files: Add
--hiddenflag - Search binary files: Add
-aor--textflag - Fix case sensitivity: Add
-i(case-insensitive) or-S(smart-case) - Test literal pattern: Try
rg -F "literal text"instead of regex - Enable multiline: Add
-Ufor patterns spanning multiple lines - Debug filtering: Use
--debugto see what's being filtered and why
flowchart TD
Start[No Results Found] --> Files{"Are expected files
being searched?"}
Files -->|Check with --files| Listed{"Files in
--files output?"}
Listed -->|No| Gitignore{"Filtered by
.gitignore?"}
Gitignore -->|Yes| UseU["Use -u/-uu/-uuu
to bypass ignores"]
Gitignore -->|No| Hidden{Hidden files?}
Hidden -->|Yes| UseHidden[Use --hidden flag]
Hidden -->|No| Type{Wrong type filter?}
Type -->|Yes| FixType["Use -g glob or
check --type-list"]
Listed -->|Yes| Binary{Binary files?}
Binary -->|Yes| UseText[Use -a/--text flag]
Binary -->|No| Case{Case mismatch?}
Case -->|Yes| UseI[Use -i or -S flag]
Case -->|No| Pattern{Pattern issue?}
Pattern -->|Regex| TestF[Test with -F literal]
Pattern -->|Multiline| UseU2[Use -U multiline]
UseU --> Retest[Re-run search]
UseHidden --> Retest
FixType --> Retest
UseText --> Retest
UseI --> Retest
TestF --> Retest
UseU2 --> Retest
Retest --> Found{Results found?}
Found -->|Yes| Success[Problem Solved]
Found -->|No| Debug[Use --debug for details]
style Start fill:#ffebee
style Files fill:#fff3e0
style Success fill:#e8f5e9
style Debug fill:#e1f5ff
Figure: Diagnostic decision tree for troubleshooting "no results" issues.
Check What Files Would Be Searched¶
Primary Diagnostic Tool: --files
First step: Use the --files flag to see which files ripgrep would search (without actually searching them):
This diagnostic flag is crucial for understanding filtering issues. If your expected files aren't in this list, they're being filtered out.
Combine --files with other filters
Files Filtered by .gitignore¶
Default Behavior: .gitignore Respected
ripgrep respects .gitignore by default and won't search ignored files. This is usually what you want, but can cause confusion when looking for files in node_modules/, target/, or other ignored directories.
Diagnosis: Run with --debug to see if files are being ignored (see Debug Flags for more details):
# Source: docs/troubleshooting/debug-flags.md
$ rg --debug "pattern"
DEBUG|ignore::walk|ignore_match: ... ignore rule IgnoreMatch(Gitignore(Explicit { from: Some(".gitignore"), original: Some("node_modules/"), ... }))
DEBUG|ignore::walk: ignoring ./node_modules: Ignore(IgnoreMatch(Gitignore(Explicit { ... }))) # (1)!
DEBUG|ignore::walk|ignore_match: ... ignore rule IgnoreMatch(Gitignore(Explicit { from: Some(".gitignore"), original: Some("target/"), ... }))
DEBUG|ignore::walk: ignoring ./target: Ignore(IgnoreMatch(Gitignore(Explicit { ... })))
- These lines show which directories are being ignored and which
.gitignorerule caused the filtering. Thefromfield indicates the source file (.gitignore), andoriginalshows the exact pattern that matched.
graph LR
All[All Files in Directory] --> VCS{".gitignore
.git/info/exclude"}
VCS -->|Filtered| Ignored1[Ignored Files]
VCS -->|Pass| Custom{".ignore
.rgignore"}
Custom -->|Filtered| Ignored2[Ignored Files]
Custom -->|Pass| Hidden{"Hidden Files
starting with ."}
Hidden -->|Filtered| Ignored3[Hidden Files]
Hidden -->|Pass| Binary{"Binary Files
with NUL bytes"}
Binary -->|Filtered| Ignored4[Binary Files]
Binary -->|Pass| Type{"File Type
-t filter"}
Type -->|Filtered| Ignored5[Non-matching Types]
Type -->|Pass| Searched[Files Searched]
style All fill:#e3f2fd
style Searched fill:#e8f5e9
style Ignored1 fill:#ffebee
style Ignored2 fill:#ffebee
style Ignored3 fill:#ffebee
style Ignored4 fill:#ffebee
style Ignored5 fill:#ffebee
Figure: ripgrep's filtering layers - files must pass all filters to be searched.
Solutions:
Ignores .gitignore and .git/info/exclude, but still respects:
.ignoreand.rgignorefiles- Hidden file filtering (files starting with
.) - Binary file filtering (files with NUL bytes)
Ignores all ignore files (.gitignore, .ignore, .rgignore), but still respects:
- Hidden file filtering (files starting with
.) - Binary file filtering (files with NUL bytes)
Completely unrestricted search - searches everything:
- Ignores all ignore files
- Searches hidden files
- Searches binary files
Hidden Files Skipped¶
Problem: ripgrep skips hidden files and directories (those starting with .) by default.
Solutions:
- Use --hidden to search hidden files
- Use -uuu to search everything including hidden files
Binary Files Filtered¶
Binary File Detection
ripgrep automatically detects and skips binary files to avoid printing garbage to your terminal. It does this by checking if the file contains a NUL byte (\0) within the first few KB of the file.
For more details, see the Binary and Encoding Problems page.
Diagnosis: Run with --debug to see binary file detection:
# Source: docs/troubleshooting/debug-flags.md
$ rg --debug "pattern"
DEBUG|grep_searcher::searcher: fast BoyerMoore search
DEBUG|grep_searcher::searcher: binary file matches (but not printed): ./myfile.bin # (1)!
DEBUG|grep_searcher::searcher: searching ./script.sh: binary detection: false
DEBUG|grep_searcher::searcher: binary file matches (but not printed): ./data.db
- These lines indicate which files were detected as binary. When "binary file matches (but not printed)" appears, it means the file was searched, matches were found, but results weren't printed because a NUL byte (
\0) was detected. Text files show "binary detection: false".
Solutions:
- Use
-aor--textto search binary files anyway - Use
--binaryto explicitly control binary file handling
Case Sensitivity¶
Problem: The pattern doesn't match because of case differences.
Solutions:
- Use -i or --ignore-case to make the search case-insensitive
- Use -S or --smart-case to search case-insensitively if the pattern is all lowercase
- Check if smart-case is enabled in your configuration file
File Type Not Recognized¶
Problem: Files are being filtered out because their type isn't recognized or matched by your -t filter.
Diagnosis: Use --type-list to see all file types ripgrep knows about:
This shows all available file types and their associated patterns. Check if your file type is listed and what extensions/patterns it matches.
Checking available file types
Solutions:
- If your file type isn't in the list, use
-gglob patterns instead of-t: - Check that you're using the correct type name (e.g.,
pynotpython) - Add custom file types in your configuration file using
--type-add:
Adding custom file types
Create or edit ~/.ripgreprc (or $RIPGREP_CONFIG_PATH):
# Source: docs/configuration-file.md
# Add custom type for web development
--type-add
web:*.{html,css,js,jsx,ts,tsx}*
# Add custom type for configuration files
--type-add
config:*.{json,yaml,yml,toml,ini}*
Then use your custom types:
For more details, see Configuration File and File Type Filtering.
Pattern Doesn't Match¶
Problem: Your regex pattern isn't matching what you expect.
Diagnosis:
- Use
-For--fixed-stringsto search for literal text instead of a regex - Test with a simpler pattern to verify the file is being searched
- Use
--debugto see the literal prefixes ripgrep extracted from your pattern
Testing literal vs regex search
Multiline Patterns
By default, patterns match within single lines only. If you need to match patterns that span multiple lines, use multiline mode:
# Source: docs/common-options/search-basics.md
# Match function definitions spanning multiple lines
$ rg -U 'fn \w+\([^)]*\)\s*->'
# Find multi-line comments
$ rg -U '/\*.*?\*/'
Note: In multiline mode (-U), the . metacharacter still doesn't match newlines by default. Use --multiline-dotall to make . match \n:
# Match struct definitions with any content between braces
$ rg -U --multiline-dotall 'struct \w+ \{.*?\}'
For more details, see Search Basics.
Common Search Recipes¶
Here are combined flag combinations for typical "no results" scenarios:
Search Everything (Nuclear Option)
This is the most permissive search - useful when you're sure the text exists but can't find it. Equivalent to disabling all filtering.
Search in node_modules or vendor directories
Bypasses .gitignore and other ignore files while still filtering binaries and hidden files.
Search Configuration Files (Including Hidden)
Includes hidden files and directories but respects ignore files and binary filtering.
Search for Exact Text (Not Regex)
Useful when your search term contains regex metacharacters (.*+?[]{}()^$|\\).
Case-Insensitive Search in All Text Files
Combines case-insensitive matching with bypassing ignore files.
Find in Specific File Types Only
Combines type filtering with bypassing .gitignore.
Debug Why Files Are Filtered
Displays which files are being ignored and why, focusing on ignore and binary detection messages.
See Also¶
- Debug Flags - Comprehensive guide to diagnostic flags
- Binary and Encoding Problems - Troubleshooting binary file and encoding issues
- Search Basics - Pattern matching fundamentals
- Configuration File - Setting up custom file types and default options