jdx/mise · error

brew-cask: generate_completions_from_executable requires at…

Error message

brew-cask: generate_completions_from_executable requires at least one shell

What it means

Thrown at the end of generate_completions_from_executable parsing. If the trailing options object has no 'shells' key, sensible defaults (bash/zsh/fish, plus pwsh for cobra/typer formats) are applied — but an explicitly present 'shells' array that resolves to empty means 'generate completions for zero shells', which is meaningless, so it bails.

Solutions

  1. Omit the "shells" key entirely to get the default shell set
  2. Or list at least one supported shell name, e.g. "shells": ["bash", "zsh", "fish", "pwsh"]

Example fix

// before
{"generate_completions_from_executable": ["mycli", {"shells": []}]}
// after
{"generate_completions_from_executable": ["mycli"]}
Defensive patterns

Strategy: validation

Validate before calling

fn completions_shells_ok(v: &serde_json::Value) -> bool {
    let arr = v.get("generate_completions_from_executable").and_then(|a| a.as_array());
    let Some(arr) = arr else { return true; };
    let opts = arr.last().and_then(|o| o.as_object());
    match opts.and_then(|o| o.get("shells")) {
        Some(serde_json::Value::Array(s)) => !s.is_empty(),
        None => true,
        Some(_) => false,
    }
}

Try / catch

match parse_generated_completion_artifact(&artifact) {
    Ok(c) => { /* proceed */ }
    Err(e) if e.to_string().contains("at least one shell") => {
        eprintln!("omit 'shells' to use defaults, or list bash/zsh/fish/pwsh explicitly");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: {"generate_completions_from_executable": ["mycli", {"shells": []}]} — the shells key exists and is an empty array; defaults are not consulted because the key was explicit.

Common situations: Templating that renders shells from an empty variable; users copying a stanza and trimming the list; YAML/JSON pipelines that collapse to empty arrays.

Related errors


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

Appendix: source

Thrown at src/system/packages/brew/cask.rs:5427

    let shells = options
        .and_then(|o| o.get("shells"))
        .and_then(Value::as_array)
        .map(|shells| {
            shells
                .iter()
                .map(|shell| {
                    let shell = shell.as_str().ok_or_else(|| {
                        eyre!("brew-cask: completion shell names must be strings")
                    })?;
                    CompletionShell::parse(shell)
                        .ok_or_else(|| eyre!("brew-cask: unsupported completion shell '{shell}'"))
                })
                .collect::<Result<Vec<_>>>()
        })
        .transpose()?
        .unwrap_or_else(|| default_generated_completion_shells(shell_parameter_format.as_deref()));
    if shells.is_empty() {
        bail!("brew-cask: generate_completions_from_executable requires at least one shell");
    }
    Ok(Some(GeneratedCompletionArtifact {
        executable,
        args,
        base_name: options
            .and_then(|o| o.get("base_name"))
            .and_then(Value::as_str)
            .map(str::to_string),
        shell_parameter_format,
        shells,
    }))
}

fn default_generated_completion_shells(format: Option<&str>) -> Vec<CompletionShell> {
    match format {
        Some("cobra") | Some("typer") => vec![
            CompletionShell::Bash,
            CompletionShell::Zsh,

View on GitHub (pinned to 6f52dcdf99)