jdx/mise · error

brew-cask: failed to generate {} completions from {}: {}

Error message

brew-cask: failed to generate {} completions from {}: {}

What it means

Some casks generate shell completions by invoking the tool itself with a completion subcommand. mise captures the subprocess's stderr and, if the generator exits nonzero, throws this error embedding the shell name, the executable path, and the trimmed stderr so the failure reason from the tool is visible.

Source

Thrown at src/system/packages/brew/cask/mod.rs:2883

    command.env("SHELL", shell.name());
    let (shell_args, shell_env) = completion_shell_parameter(
        completion.shell_parameter_format.as_deref(),
        shell,
        executable,
    );
    command.args(shell_args);
    for (key, value) in shell_env {
        command.env(key, value);
    }
    let output = command.output().wrap_err_with(|| {
        format!(
            "failed to generate {} completions from {}",
            shell.name(),
            executable.display()
        )
    })?;
    if !output.status.success() {
        bail!(
            "brew-cask: failed to generate {} completions from {}: {}",
            shell.name(),
            executable.display(),
            String::from_utf8_lossy(&output.stderr).trim()
        );
    }
    Ok(String::from_utf8_lossy(&output.stdout).into_owned())
}

fn completion_shell_parameter(
    format: Option<&str>,
    shell: CompletionShell,
    executable: &Path,
) -> (Vec<String>, Vec<(String, String)>) {
    let shell_parameter = shell.parameter_name().to_string();
    match format {
        None => (vec![shell_parameter], Vec::new()),
        Some("arg") => (vec![format!("--shell={shell_parameter}")], Vec::new()),

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Read the embedded stderr in the message — it usually states the tool's own failure reason
  2. Run the completion command manually against the staged executable to reproduce: `<exe> <completion-args> <shell>`
  3. Update the cask or mise if the tool renamed its completion subcommand/shell name
  4. Skip completion generation for this cask or file an issue with the cask maintainer

Example fix

// before: tool rejects unsupported shell in cask stanza
completions "tcsh"
// after: use a supported shell
completions "zsh"
Defensive patterns

Strategy: try-catch

Validate before calling

<staged-exe> --completions zsh >/dev/null 2>&1 && echo ok || echo "completion generation fails: run manually to see stderr"

Try / catch

match result {
  Err(e) if e.contains("failed to generate") && e.contains("completions") => {
    eprintln!("tool rejected completion generation; run the executable manually to see its stderr: {e}");
  }
  Err(e) => return Err(e),
  Ok(v) => v,
}

Prevention

When it happens

Trigger: `output.status.success()` is false after running `<executable> --completions <shell>` (or equivalent) — the tool rejects the shell argument, can't find its config, or crashes during completion generation.

Common situations: The staged executable requires initialization (missing config dir, first-run) before generating completions; the cask declares a shell the tool doesn't support; a version change renamed the completion subcommand; the binary fails under the staging environment.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/f155baa84ff84e2f. Report an issue: GitHub.