jdx/mise · error

trimPrefix requires exactly 2 arguments

Error message

trimPrefix requires exactly 2 arguments

What it means

Arity check in the template function registry: `trimPrefix` requires the prefix and the text (two arguments, in that order); the template invoked it with a different count, so the closure bails before stripping.

Solutions

  1. Call trimPrefix with two arguments: prefix first, then the text, e.g. `(trimPrefix "v" .Version)`
  2. Use trimV when the prefix is simply 'v'
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/aqua-registry/src/template.rs:367 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/9977f219c47f5916. Report an issue: GitHub.

Appendix: source

Thrown at crates/aqua-registry/src/template.rs:367

    registry.insert("title", |args| {
        if args.len() != 1 {
            bail!("title requires exactly 1 argument");
        }
        Ok(Box::new(StringValue(args[0].as_string().to_title_case())) as Box<dyn Value>)
    });

    registry.insert("trimV", |args| {
        if args.len() != 1 {
            bail!("trimV requires exactly 1 argument");
        }
        Ok(Box::new(StringValue(
            args[0].as_string().trim_start_matches('v').to_string(),
        )) as Box<dyn Value>)
    });

    registry.insert("trimPrefix", |args| {
        if args.len() != 2 {
            bail!("trimPrefix requires exactly 2 arguments");
        }
        let prefix = args[0].as_string();
        let text = args[1].as_string();
        Ok(Box::new(StringValue(
            text.strip_prefix(&prefix).unwrap_or(&text).to_string(),
        )) as Box<dyn Value>)
    });

    registry.insert("trimSuffix", |args| {
        if args.len() != 2 {
            bail!("trimSuffix requires exactly 2 arguments");
        }
        let suffix = args[0].as_string();
        let text = args[1].as_string();
        Ok(Box::new(StringValue(
            text.strip_suffix(&suffix).unwrap_or(&text).to_string(),
        )) as Box<dyn Value>)
    });

View on GitHub (pinned to 533346cc37)