pola-rs/polars · error

unknown argument

Error message

unknown argument: `{unknown}`

What it means

The binary accepts exactly two CLI arguments: the subcommand and an optional path. Any third (or later) argument reaches this check and triggers `panic!("unknown argument: `{unknown}`")`. This strictness prevents silently ignoring typo'd or leftover flags.

Solutions

  1. Remove the extra arguments; only `<command> [path]` is accepted.
  2. If you intended a flag, check the binary's source — no flags are parsed, only two positionals.
  3. Quote paths with spaces as a single argument so they don't split into multiple args.

Example fix

// before
dsl-schema generate ./out.json --pretty

// after
dsl-schema generate ./out.json
Defensive patterns

Strategy: validation

Validate before calling

# shellcheck
cmd="$1"; path="$2"; shift 2 || true
if [ "$#" -gt 0 ]; then echo "extra args not allowed" >&2; exit 1; fi

Prevention

When it happens

Trigger: Calling the binary with more than two positional arguments, e.g. `dsl-schema generate out.json extra`, or passing flags like `--force` which the binary does not parse.

Common situations: Adding flags habitually (`--verbose`, `--output`) that this minimal CLI does not support; shell scripts appending extra variables that expand into extra positional args.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/329455cf48bb1fab. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-plan/src/bin/dsl-schema.rs:52

    use std::path::Path;

    use polars_plan::dsl::DslPlan;
    use schemars::Schema;
    use sha2::Digest;

    const DEFAULT_HASHES_PATH: &str = "crates/polars-plan/dsl-schema-hashes.json";

    pub fn run() {
        let mut args = std::env::args();

        let _ = args.next();
        let cmd = args
            .next()
            .expect("missing command [generate, update-hashes, check-hashes]");
        let path = args.next();

        if let Some(unknown) = args.next() {
            panic!("unknown argument: `{unknown}`");
        }

        match cmd.as_str() {
            "generate" => {
                generate(path.unwrap_or("./dsl-schema.json".to_owned()));
            },
            "update-hashes" => {
                update_hashes(path.unwrap_or(DEFAULT_HASHES_PATH.to_owned()));
            },
            "check-hashes" => {
                check_hashes(path.unwrap_or(DEFAULT_HASHES_PATH.to_owned()));
            },
            unknown => {
                panic!("unknown command: `{unknown}`");
            },
        }
    }

View on GitHub (pinned to fe841f959e)