clap-rs/clap · error

Command {}: Argument '{}' has the same index as '{}' and the

Error message

Command {}: Argument '{}' has the same index as '{}' and they are both positional arguments

	 Use `Arg::num_args(1..)` to allow one positional argument to take multiple values

What it means

Error "Command {}: Argument '{}' has the same index as '{}' and they are both positional arguments Use `Arg::num_args(1..)` to allow one positional argument to take multiple values" thrown in clap-rs/clap.

Source

Thrown at clap_builder/src/builder/debug_asserts.rs:142

            if let Some((first, second)) = cmd.two_args_of(|x| x.get_short() == Some(s)) {
                panic!(
                    "Command {}: Short option names must be unique for each argument, \
                            but '-{}' is in use by both '{}' and '{}'{}",
                    cmd.get_name(),
                    s,
                    first.get_id(),
                    second.get_id(),
                    duplicate_tip(cmd, first, second),
                )
            }
        }

        // Index conflicts
        if let Some(idx) = arg.index {
            if let Some((first, second)) =
                cmd.two_args_of(|x| x.is_positional() && x.get_index() == Some(idx))
            {
                panic!(
                    "Command {}: Argument '{}' has the same index as '{}' \
                    and they are both positional arguments\n\n\t \
                    Use `Arg::num_args(1..)` to allow one \
                    positional argument to take multiple values",
                    cmd.get_name(),
                    first.get_id(),
                    second.get_id()
                )
            }
        }

        // requires, r_if, r_unless
        for (_predicate, req_id) in &arg.requires {
            assert!(
                &arg.id != req_id,
                "Argument {} cannot require itself",
                arg.get_id()
            );

View on GitHub (pinned to 5b81f1012d)

When it happens

Trigger: Thrown at clap_builder/src/builder/debug_asserts.rs:142 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of clap-rs/clap@5b81f1012d (2026-08-18). Data as JSON: /api/errors/cc5d3ce7177dfe4b. Report an issue: GitHub.