{"record":{"id":"ec3bf1a6007d167f","repo":"jdx/mise","slug":"brew-cask-failed-to-generate-completions-from","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.rs","lineNumber":4354,"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":4336,"sourceCodeEnd":4372,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L4336-L4372","documentation":"To produce shell completions for a cask, mise executes the staged executable with the stanza's args, sets SHELL to the target shell, and adds a shell parameter (e.g. --zsh) derived from shell_parameter_format. This error fires when that subprocess either cannot be spawned (wrapped spawn failure) or exits non-zero; the message embeds the executable path and the trimmed stderr of the run. It means the completion-generation contract between the cask stanza and the binary failed at runtime.","triggerScenarios":"Running `mise install` (or use/upgrade) of a brew-cask whose generated completion stanza invokes a binary that: rejects the completion flags used (wrong args or wrong shell_parameter_format), needs an interpreter (python/node) missing from mise's execution environment, is a macOS Mach-O binary run on an unsupported context, or crashes before emitting stdout. The non-success branch at src/system/packages/brew/cask.rs:4354 includes the binary's stderr verbatim.","commonSituations":"A cask stanza passes args like [\"completions\", \"zsh\"] but the shipped CLI expects `completion zsh` (singular) or only supports `--generate-completion`; upstream CLI versions that changed their completion subcommand; binaries that require HOME/XDG env vars that are unset in the install context; executables that are actually scripts with a missing shebang interpreter.","solutions":["Reproduce manually: run the exact staged executable with the stanza's args plus the shell flag and SHELL=<shell> set, and read the stderr the error already includes — a usage/parse error means the stanza's args or shell_parameter_format are wrong for this binary version.","Fix the stanza: adjust 'args' and 'shell_parameter_format' so the binary's own completion command is invoked correctly (check the CLI's --help).","If the binary depends on a runtime or env (python, node, HOME), install/provide it before running mise install, or export the needed variables.","If completion generation is optional for you, remove/disable the generated-completion stanza for that cask so install proceeds without completions.","Report the stanza upstream (cask metadata repo) if the CLI changed its completion interface and the stanza is stale."],"exampleFix":"# before — stanza assumes clap-style flags but binary wants a subcommand\n\"generated\": [{ \"executable\": \"bin/tool\", \"args\": [\"--zsh\"] }]\n\n# after\n\"generated\": [{ \"executable\": \"bin/tool\", \"args\": [\"completion\", \"zsh\"] }]","handlingStrategy":"try-catch","validationCode":"# smoke-test completion generation before relying on install\nBIN=\"<caskroom>/bin/tool\"\nSHELL=zsh \"$BIN\" <stanza-args> <shell-flag> >/dev/null || echo \"completion generation will fail; fix stanza args\"","typeGuard":null,"tryCatchPattern":"let out = std::process::Command::new(&exe).args(&args).output();\nmatch out {\n    Ok(o) if o.status.success() => String::from_utf8_lossy(&o.stdout).into_owned(),\n    Ok(o) => {\n        // degrade gracefully: log stderr, skip completions, keep the install going\n        warn!(\"completion generation failed: {}\", String::from_utf8_lossy(&o.stderr).trim());\n        None\n    }\n    Err(e) => { warn!(\"failed to spawn {}: {e}\", exe.display()); None }\n}","preventionTips":["After any CLI version bump, re-run its completion command manually to confirm the stanza's flags still work.","Keep the stanza's args in lockstep with the CLI's documented completion subcommand.","Treat completions as optional: script installs so a completion failure does not abort the whole install."],"tags":["brew-cask","completions","subprocess","mise","cli-exit-code"],"backgroundTag":"subprocess-exit-failure","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}