jdx/mise · error · eyre::Report
trimPrefix requires exactly 2 arguments
Error message
trimPrefix requires exactly 2 arguments
What it means
Each key of a command_wrapper 'env' mapping is validated by is_shell_env_name: it must start with an ASCII letter or underscore, and every following character must be ASCII alphanumeric or underscore (classic shell identifier rules). Keys like 'FOO-BAR', '1FOO', '' or 'FOO.BAR' are rejected.
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 9dcfcaa0dc)
Solutions
- Rename the env key to match [_A-Za-z][_A-Za-z0-9]* (e.g. FOO_BAR instead of FOO-BAR)
- If the wrapped tool truly requires a weird env name, set it inside the 'content' script instead of the env map
Example fix
# before
{"command_wrapper": ["tool", {"executable": "bin/tool", "env": {"my-tool-mode": "1"}}]}
# after
{"command_wrapper": ["tool", {"executable": "bin/tool", "env": {"MY_TOOL_MODE": "1"}}]} Defensive patterns
Strategy: validation
Validate before calling
fn is_shell_env_name(v: &str) -> bool {
let mut cs = v.chars();
cs.next().is_some_and(|c| c == '_' || c.is_ascii_alphabetic())
&& cs.all(|c| c == '_' || c.is_ascii_alphanumeric())
}
// pre-check every env key before install
assert!(env.keys().all(|k| is_shell_env_name(k))); Type guard
fn is_shell_env_name(v: &str) -> bool {
let mut cs = v.chars();
cs.next().is_some_and(|c| c == '_' || c.is_ascii_alphabetic())
&& cs.all(|c| c == '_' || c.is_ascii_alphanumeric())
} Prevention
- Use UPPER_SNAKE_CASE names for wrapper env keys
- Put non-identifier env names inside the content script, not the env map
When it happens
Trigger: env mappings with hyphenated, dotted, digit-leading, empty, or non-ASCII keys in command_wrapper metadata.
Common situations: Copying env names from YAML configs where dashes are legal; prefixed variables like 'tool.VERSION'; Unicode key names from generated JSON.
Related errors
- mise prune --monorepo is not implemented yet
- expected identifier after dot
- semver requires exactly 1 argument
- title requires exactly 1 argument
- trimV requires exactly 1 argument
AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17).
Data as JSON: /api/errors/9977f219c47f5916.
Report an issue: GitHub.