jdx/mise · error · eyre::Report

trimSuffix requires exactly 2 arguments

Error message

trimSuffix requires exactly 2 arguments

What it means

`path:` tool specifiers name a local tool directory. On Windows, backslashes are normally rewritten to `/` before validation, so the only backslash that survives `validate_path_string` (src/toolset/tool_request.rs) is a `\\?\` extended-length or `\\.\` device prefix — mise reports that specifically: `invalid tool path {s}: extended-length and device paths (\\?\, \\.\) are not supported`. These prefixes would corrupt `ctx.rootPath`/`installPath` and shell interpolation in plugin hooks.

Source

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

        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>)
    });

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

View on GitHub (pinned to 6f52dcdf99)

Solutions

  1. Drop the prefix and use a normal path with forward slashes: `path:C:/dev/node`.
  2. Use a relative path from the config file: `path:../tools/node`.
  3. Shorten or move the project so tooling stops emitting extended-length paths.
  4. If a tool itself only prints `\\?\` paths, strip the prefix in the script that writes mise.toml.

Example fix

# before
$ mise use node@path:'\\\\?\\C:\\dev\\node22'

# after
$ mise use node@path:C:/dev/node22
Defensive patterns

Strategy: validation

Validate before calling

# reject verbatim/device prefixes in path: specs before mise sees them
python3 -c '
import sys
p = sys.argv[1].split(":", 1)[1] if ":" in sys.argv[1] else ""
sys.exit("verbatim path" if p.startswith("\\\\\\\\?\\\\") or p.startswith("\\\\\\\\.\\\\") else 0)
' -- 'path:\\\\?\\C:\\dev\\node' || echo REJECT

Type guard

function isSupportedToolPath(p: string): boolean {
  return !(p.startsWith("\\\\?\\") || p.startsWith("\\\\.\\"));
}

Prevention

When it happens

Trigger: `mise use node@path:\\\\?\\C:\\dev\\node` or `path:\\.\\C:\\dev\\node` on Windows — paths copied from PowerShell (`Convert-Path` on long paths), Explorer properties, or tools that emit verbatim paths for paths over 260 characters.

Common situations: Long repository paths exceeding MAX_PATH causing tools to return `\\?\`-prefixed paths that get pasted into mise.toml; automation scripts passing `\?\` device paths; users assuming verbatim paths are the 'safe' form for Windows.

Related errors


AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22). Data as JSON: /api/errors/ae2245f85564e3a1. Report an issue: GitHub.