{"id":"1864ce8cda32ab94","repo":"BurntSushi/ripgrep","slug":"x-index-may-be-given-at-most-twice","errorCode":null,"errorMessage":"-X/--index may be given at most twice","messagePattern":"-X/--index may be given at most twice","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/core/flags/defs.rs","lineNumber":3515,"sourceCode":".sp\nIndexed candidates are filtered by explicit glob and file-type selections,\nhidden-file and depth settings, and the maximum file size. Ignore files,\nincluding \\fB.gitignore\\fP, are not read or reapplied during an indexed search.\nOptions that require transformed contents or every file make the query\nineligible for candidate filtering and therefore trigger the fallback below.\n.sp\nThis flag may be given at most twice. When it is given once and the query\ncannot use an index, ripgrep performs an ordinary search. When it is given\ntwice and an index was found, ripgrep stops instead of performing an ordinary\nsearch if the query cannot use the index.\n\"\n    }\n\n    fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {\n        check_indexing_allowed()?;\n        assert!(v.unwrap_switch(), \"--index has no negation\");\n        args.index = args.index.saturating_add(1);\n        anyhow::ensure!(\n            args.index <= 2,\n            \"-X/--index may be given at most twice\"\n        );\n        Ok(())\n    }\n}\n\n#[cfg(test)]\n#[test]\nfn test_index() {\n    if !cfg!(feature = \"unstable-index\") {\n        assert!(parse_low_raw([\"-X\"]).is_err());\n        return;\n    }\n\n    let args = parse_low_raw(None::<&str>).unwrap();\n    assert_eq!(0, args.index);\n    assert_eq!(Mode::Search(SearchMode::Standard), args.mode);","sourceCodeStart":3497,"sourceCodeEnd":3533,"githubUrl":"https://github.com/BurntSushi/ripgrep/blob/3fce3b5bb0236da2df6d99672afb8a719642eca7/crates/core/flags/defs.rs#L3497-L3533","documentation":"Error \"-X/--index may be given at most twice\" thrown in BurntSushi/ripgrep.","triggerScenarios":"Thrown at crates/core/flags/defs.rs:3515 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass -X/--index no more than two times on the command line","Remove redundant occurrences of the flag"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"3fce3b5bb0236da2df6d99672afb8a719642eca7","analyzedAt":"2026-08-06T01:39:05.073Z","schemaVersion":2}