jdx/mise · error

':task' pattern should be expanded before matching

Error message

':task' pattern should be expanded before matching

What it means

This is an internal-consistency error: `:task` patterns are supposed to be expanded (to their concrete '//dir:task' form) before get_matching runs. Reaching the ':'' branch inside get_matching means an earlier expansion step was skipped, so mise bails rather than guessing the directory.

Solutions

  1. Upgrade mise — this usually indicates an internal bug that may already be fixed
  2. Work around by writing the pattern as '//<path>:task' instead of ':task'
  3. File a bug report with the exact command that produced it

Example fix

// before
mise run :build

// after
mise run //current/dir:build
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await run(['mise', 'run', task]);
} catch (e) {
  if (e.message.includes("':task' pattern should be expanded")) {
    console.error('mise internal bug; upgrade mise or use //path:task form');
  }
  throw e;
}

Prevention

When it happens

Trigger: A code path (or plugin/extension) calls the pattern matcher directly with a raw ':build' pattern instead of first expanding it via the task-context expansion step; normally unreachable from the CLI.

Common situations: Rarely hit by users; appears when internal refactors skip expansion or when scripting against mise internals. Report it as a bug if seen from a normal `mise run` invocation.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/task/mod.rs:3579

                .map(|(_, task)| task)
                .unique()
                .collect();
            if !matched.is_empty() {
                return Ok(matched);
            }
            if self.keys().any(|k| k.starts_with("//")) {
                return self.get_matching(&format!("//{pat}"));
            }
            return Ok(vec![]);
        }

        // === Parse monorepo pattern ===
        let normalized_pat = if pat.starts_with("//") {
            pat.to_string()
        } else if pat.starts_with(':') {
            // Special case: :task should have been expanded before calling get_matching
            // If we reach here, it means the expansion didn't happen properly
            bail!("':task' pattern should be expanded before matching")
        } else {
            pat.to_string()
        };

        // Split pattern into path and task parts
        // Pattern format: //path/...:task* or //path:task*
        let parts: Vec<&str> = normalized_pat.splitn(2, ':').collect();
        if pat.starts_with("//") && parts.len() == 1 {
            bail!(
                "missing task name in monorepo path '{}', use '{}:<task>' or '{}:*' to run all tasks in that path",
                pat,
                pat,
                pat
            );
        }
        let (path_pattern, task_pattern) = match parts.as_slice() {
            [path, task] => (*path, *task),
            [path] => (*path, "*"),

View on GitHub (pinned to 533346cc37)