{"record":{"id":"f155baa84ff84e2f","repo":"jdx/mise","slug":"brew-cask-failed-to-generate-completions-from-f155ba","errorCode":null,"errorMessage":"brew-cask: failed to generate {} completions from {}: {}","messagePattern":"brew-cask: failed to generate (.+?) completions from (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/mod.rs","lineNumber":2883,"sourceCode":"    command.env(\"SHELL\", shell.name());\n    let (shell_args, shell_env) = completion_shell_parameter(\n        completion.shell_parameter_format.as_deref(),\n        shell,\n        executable,\n    );\n    command.args(shell_args);\n    for (key, value) in shell_env {\n        command.env(key, value);\n    }\n    let output = command.output().wrap_err_with(|| {\n        format!(\n            \"failed to generate {} completions from {}\",\n            shell.name(),\n            executable.display()\n        )\n    })?;\n    if !output.status.success() {\n        bail!(\n            \"brew-cask: failed to generate {} completions from {}: {}\",\n            shell.name(),\n            executable.display(),\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n}\n\nfn completion_shell_parameter(\n    format: Option<&str>,\n    shell: CompletionShell,\n    executable: &Path,\n) -> (Vec<String>, Vec<(String, String)>) {\n    let shell_parameter = shell.parameter_name().to_string();\n    match format {\n        None => (vec![shell_parameter], Vec::new()),\n        Some(\"arg\") => (vec![format!(\"--shell={shell_parameter}\")], Vec::new()),","sourceCodeStart":2865,"sourceCodeEnd":2901,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/cask/mod.rs#L2865-L2901","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Read the embedded stderr in the message — it usually states the tool's own failure reason","Run the completion command manually against the staged executable to reproduce: `<exe> <completion-args> <shell>`","Update the cask or mise if the tool renamed its completion subcommand/shell name","Skip completion generation for this cask or file an issue with the cask maintainer"],"exampleFix":"// before: tool rejects unsupported shell in cask stanza\ncompletions \"tcsh\"\n// after: use a supported shell\ncompletions \"zsh\"","handlingStrategy":"try-catch","validationCode":"<staged-exe> --completions zsh >/dev/null 2>&1 && echo ok || echo \"completion generation fails: run manually to see stderr\"","typeGuard":null,"tryCatchPattern":"match result {\n  Err(e) if e.contains(\"failed to generate\") && e.contains(\"completions\") => {\n    eprintln!(\"tool rejected completion generation; run the executable manually to see its stderr: {e}\");\n  }\n  Err(e) => return Err(e),\n  Ok(v) => v,\n}","preventionTips":["Only declare completion shells the tool actually supports","Verify the completion subcommand after tool version upgrades","Initialize the tool's config before relying on completion generation"],"tags":["brew-cask","completions","subprocess","command-failed"],"backgroundTag":"command-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}