BurntSushi/ripgrep · error
-X/--index may be given at most twice
Error message
-X/--index may be given at most twice
What it means
Error "-X/--index may be given at most twice" thrown in BurntSushi/ripgrep.
Source
Thrown at crates/core/flags/defs.rs:3515
.sp
Indexed candidates are filtered by explicit glob and file-type selections,
hidden-file and depth settings, and the maximum file size. Ignore files,
including \fB.gitignore\fP, are not read or reapplied during an indexed search.
Options that require transformed contents or every file make the query
ineligible for candidate filtering and therefore trigger the fallback below.
.sp
This flag may be given at most twice. When it is given once and the query
cannot use an index, ripgrep performs an ordinary search. When it is given
twice and an index was found, ripgrep stops instead of performing an ordinary
search if the query cannot use the index.
"
}
fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {
check_indexing_allowed()?;
assert!(v.unwrap_switch(), "--index has no negation");
args.index = args.index.saturating_add(1);
anyhow::ensure!(
args.index <= 2,
"-X/--index may be given at most twice"
);
Ok(())
}
}
#[cfg(test)]
#[test]
fn test_index() {
if !cfg!(feature = "unstable-index") {
assert!(parse_low_raw(["-X"]).is_err());
return;
}
let args = parse_low_raw(None::<&str>).unwrap();
assert_eq!(0, args.index);
assert_eq!(Mode::Search(SearchMode::Standard), args.mode);View on GitHub (pinned to 3fce3b5bb0)
Solutions
- Pass -X/--index no more than two times on the command line
- Remove redundant occurrences of the flag
When it happens
Trigger: Thrown at crates/core/flags/defs.rs:3515 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/1864ce8cda32ab94.json.
Report an issue: GitHub.