jdx/mise · error

directive requires exactly one argument

Error message

directive requires exactly one argument

What it means

For a plain (unquoted) directive argument, parse_argument requires the remaining text to be exactly one whitespace-delimited token. If it contains multiple tokens, the directive would have more than one argument, which module/use do not allow, so it bails with 'directive requires exactly one argument'.

Solutions

  1. Split multiple directories onto separate `use` lines, or group them in a `use ( ... )` block.
  2. Remove the extra token/trailing garbage from the line.
  3. Quote the single value if it contains spaces (paths with spaces must be quoted, which also satisfies the parser).

Example fix

// before (go.work)
use ./a ./b

// after
use (
  ./a
  ./b
)
Defensive patterns

Strategy: validation

Validate before calling

// shell
grep -nE '^[ \t]*(use|module)[ \t]+[^ (][^ ]*[ \t]+[^ ]' go.work go.mod && { echo 'too many arguments on directive line'; exit 1; } || true

Prevention

When it happens

Trigger: A `use` or `module` line in go.work/go.mod carries two or more unquoted space-separated tokens, e.g. `use ./a ./b` or trailing garbage after the path.

Common situations: Listing multiple directories on one use line (must be separate lines or a use block); stray trailing text left by a bad sed/regex edit; a comment not stripped properly leaving extra tokens.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src/task/workspace/go.rs:199

        bail!("directive requires one argument");
    }
    if let Some(value) = value.strip_prefix('"') {
        let Some(value) = value.strip_suffix('"') else {
            bail!("unterminated interpreted Go string");
        };
        return unescape_go_string(value);
    }
    if let Some(value) = value.strip_prefix('`') {
        let Some(value) = value.strip_suffix('`') else {
            bail!("unterminated raw Go string");
        };
        if value.contains('`') {
            bail!("unexpected raw Go string delimiter");
        }
        return Ok(value.to_string());
    }
    if value.split_whitespace().count() != 1 {
        bail!("directive requires exactly one argument");
    }
    Ok(value.to_string())
}

fn unescape_go_string(value: &str) -> Result<String> {
    let mut characters = value.chars();
    let mut unescaped = String::new();
    while let Some(character) = characters.next() {
        if character == '"' {
            bail!("unexpected interpreted Go string delimiter");
        }
        if character != '\\' {
            unescaped.push(character);
            continue;
        }
        let escape = characters
            .next()
            .ok_or_else(|| eyre::eyre!("unterminated Go string escape"))?;

View on GitHub (pinned to 533346cc37)