BurntSushi/ripgrep · error

unrecognized flag -{name}

Error message

unrecognized flag -{name}

What it means

Error "unrecognized flag -{name}" thrown in BurntSushi/ripgrep.

Source

Thrown at crates/core/flags/parse.rs:263

                lexopt::Arg::Short(ch) => self.find_short(ch),
                lexopt::Arg::Long(name) if name == "help" => {
                    // Special case -h/--help since behavior is different
                    // based on whether short or long flag is given.
                    args.special = Some(SpecialMode::HelpLong);
                    continue;
                }
                lexopt::Arg::Long(name) if name == "version" => {
                    // Special case -V/--version since behavior is different
                    // based on whether short or long flag is given.
                    args.special = Some(SpecialMode::VersionLong);
                    continue;
                }
                lexopt::Arg::Long(name) => self.find_long(name),
            };
            let mat = match lookup {
                FlagLookup::Match(mat) => mat,
                FlagLookup::UnrecognizedShort(name) => {
                    anyhow::bail!("unrecognized flag -{name}")
                }
                FlagLookup::UnrecognizedLong(name) => {
                    let mut msg = format!("unrecognized flag --{name}");
                    if let Some(suggest_msg) = suggest(&name) {
                        msg = format!("{msg}\n\n{suggest_msg}");
                    }
                    anyhow::bail!("{msg}")
                }
            };
            let value = if matches!(mat.kind, FlagInfoKind::Negated) {
                // Negated flags are always switches, even if the non-negated
                // flag is not. For example, --context-separator accepts a
                // value, but --no-context-separator does not.
                FlagValue::Switch(false)
            } else if mat.flag.is_switch() {
                FlagValue::Switch(true)
            } else {
                FlagValue::Value(p.value().with_context(|| {

View on GitHub (pinned to 3fce3b5bb0)

Solutions

  1. Check the short flag spelling; run --help for the list of valid flags
  2. Use the long form of the flag if the short form does not exist

When it happens

Trigger: Thrown at crates/core/flags/parse.rs:263 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/3e6551b7b7259996.json. Report an issue: GitHub.