BurntSushi/ripgrep · error
ripgrep requires at least one pattern to execute a search
Error message
ripgrep requires at least one pattern to execute a search
What it means
Error "ripgrep requires at least one pattern to execute a search" thrown in BurntSushi/ripgrep.
Source
Thrown at crates/core/flags/hiargs.rs:1033
/// extracted as well.
fn from_low_args(
state: &mut State,
low: &mut LowArgs,
) -> anyhow::Result<Patterns> {
// The first positional is only a pattern when ripgrep is instructed to
// search and neither -e/--regexp nor -f/--file is given. Basically,
// the first positional is a pattern only when a pattern hasn't been
// given in some other way.
// No search means no patterns. Even if -e/--regexp or -f/--file is
// given, we know we won't use them so don't bother collecting them.
if !matches!(low.mode, Mode::Search(_)) {
return Ok(Patterns { patterns: vec![] });
}
// If we got nothing from -e/--regexp and -f/--file, then the first
// positional is a pattern.
if low.patterns.is_empty() {
anyhow::ensure!(
!low.positional.is_empty(),
"ripgrep requires at least one pattern to execute a search"
);
let ospat = low.positional.remove(0);
let Ok(pat) = ospat.into_string() else {
anyhow::bail!("pattern given is not valid UTF-8")
};
return Ok(Patterns { patterns: vec![pat] });
}
// Otherwise, we need to slurp up our patterns from -e/--regexp and
// -f/--file. We de-duplicate as we go. If we don't de-duplicate,
// then it can actually lead to major slow downs for sloppy inputs.
// This might be surprising, and the regex engine will eventually
// de-duplicate duplicative branches in a single regex (maybe), but
// not until after it has gone through parsing and some other layers.
// If there are a lot of duplicates, then that can lead to a sizeable
// extra cost. It is lamentable that we pay the extra cost here to
// de-duplicate for a likely uncommon case, but I've seen this have aView on GitHub (pinned to 3fce3b5bb0)
Solutions
- Provide at least one pattern as a positional argument or via -e/--regexp or -f/--file
When it happens
Trigger: Thrown at crates/core/flags/hiargs.rs:1033 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BurntSushi/ripgrep@3fce3b5bb0 (2026-08-06).
Data as JSON: /data/errors/2b73cf3cf23f06ea.json.
Report an issue: GitHub.