Morganamilo/paru · error

option does not allow a value

Error message

option {} does not allow a value

What it means

The parser rejected a value attached to an option that does not accept one (`TakesValue::No`) when `forced` is set, bailing with 'option {} does not allow a value'. This happens when `parse_arg` forced a value onto a boolean-style flag.

Solutions

  1. Remove the `=value` from the boolean flag: use `--stats` alone
  2. Use the correct option that takes a value (e.g. `--limit 5`) instead of adding a value to a boolean one
  3. Repeat boolean flags to increase counts where supported (e.g. `-w` for news count)

Example fix

// before
paru --stats=true
// after
paru --stats
Defensive patterns

Strategy: validation

Validate before calling

const NO_VALUE_FLAGS = new Set(['stats', 'news', 'installdebug', 'noinstalldebug', 'nosign', 'nosigndb']);
function reject_valued_bools(args: string[]): string | null {
  for (const a of args) {
    const [name, val] = a.split('=');
    if (val !== undefined && NO_VALUE_FLAGS.has(name.replace(/^--/, '')))
      return `--${name} does not allow a value`;
  }
  return null;
}

Try / catch

if (let Err(e) = cli::parse(&args)) && e.to_string().contains("does not allow a value") {
    eprintln!("{} — drop the =value for boolean flags", e);
}

Prevention

When it happens

Trigger: Passing `=value` or a following value to a flagless option, e.g. `--stats=true`, `--news=2`, or `--installdebug yes`; the value is only rejected when `forced` is true (value was explicitly attached/passed).

Common situations: Users habitually adding `=value` to boolean flags; scripts templating `--flag=${VAR}` where flag is boolean; confusion with GNU long-option `=` syntax.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of Morganamilo/paru@9ac3578807 (2026-09-12). Data as JSON: /api/errors/17b991b83ad0179c. Report an issue: GitHub.

Appendix: source

Thrown at src/command_line.rs:382

            Arg::Long("signdb") => {
                self.sign_db = match value {
                    Ok(k) => Sign::Key(k.to_string()),
                    Err(_) => Sign::Yes,
                }
            }
            Arg::Long("nosign") => self.sign = Sign::No,
            Arg::Long("nosigndb") => self.sign_db = Sign::No,
            Arg::Long(a) if !arg.is_pacman_arg() && !arg.is_pacman_global() => {
                bail!(tr!("unknown option --{}", a))
            }
            Arg::Short(a) if !arg.is_pacman_arg() && !arg.is_pacman_global() => {
                bail!(tr!("unknown option -{}", a))
            }
            _ => (),
        }

        match takes_value(arg) {
            TakesValue::No if forced => bail!(tr!("option {} does not allow a value", arg)),
            _ => (),
        }

        Ok(())
    }
}

fn split_whitespace(s: &str) -> Vec<String> {
    s.split_whitespace().map(|s| s.to_string()).collect()
}

fn takes_value(arg: Arg) -> TakesValue {
    match arg {
        Arg::Long("aururl") => TakesValue::Required,
        Arg::Long("aurrpcurl") => TakesValue::Required,
        Arg::Long("editor") => TakesValue::Required,
        Arg::Long("makepkg") => TakesValue::Required,
        Arg::Long("pacman") => TakesValue::Required,

View on GitHub (pinned to 9ac3578807)