jdx/mise · error

brew-cask: invalid completion target

Error message

brew-cask: invalid completion target '{target_name}'

What it means

This error is thrown by completion_filename when, after normalizing a bare (no-slash) completion target name for the target shell, the resulting filename is empty. That means the caller passed an empty or stem-less target name (e.g. "", ".fish", ".ps1", or just "_") so no valid completion file name can be derived.

Solutions

  1. Set the completion target to the tool's actual name (e.g. "mytool"), letting the shell-specific suffix/underscore be added automatically.
  2. Remove the empty completion entry from the cask if the cask ships no completions.
  3. Fix the template or variable that produced an empty name before it reaches the manifest.
  4. Validate cask manifests (target non-empty and non-extension-only) before installing.

Example fix

// before
completions = [{ target = "" }]
// after
completions = [{ target = "mytool" }]
Defensive patterns

Strategy: validation

Validate before calling

fn valid_bare_target(name: &str) -> bool {
    let stem = std::path::Path::new(name).file_stem().and_then(|s| s.to_str()).unwrap_or("");
    !name.trim().is_empty() && !stem.trim().is_empty()
}
// reject the completion entry when !valid_bare_target(target)

Prevention

When it happens

Trigger: A cask completion entry with a bare target_name that is empty, or reduces to an empty stem after stripping extension/underscore normalization (e.g. target ".fish" for fish, ".ps1" for pwsh, "_" handling edge cases), triggering the normalized.is_empty() bail.

Common situations: A hand-edited cask with an empty completions target string; a templated cask where a name variable expanded to nothing; a target given as only a file extension; programmatic generation of cask manifests leaving the completion target blank.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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

Appendix: source

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

            }
        }
        CompletionShell::Zsh => {
            if filename.starts_with('_') {
                filename.to_string()
            } else {
                format!("_{stem}")
            }
        }
        CompletionShell::Pwsh => {
            if filename.ends_with(".ps1") {
                filename.to_string()
            } else {
                format!("{stem}.ps1")
            }
        }
    };
    if normalized.is_empty() {
        bail!("brew-cask: invalid completion target '{target_name}'");
    }
    Ok(normalized)
}

fn caskroom_completion_path(caskroom: &Path, target: &Path) -> Result<PathBuf> {
    let prefix = prefix::prefix();
    let relative = target.strip_prefix(&prefix).map_err(|_| {
        eyre!(
            "brew-cask: completion target '{}' must be under {}",
            target.display(),
            prefix.display()
        )
    })?;
    if relative.components().next().is_none() {
        bail!(
            "brew-cask: invalid completion target '{}'",
            target.display()
        );

View on GitHub (pinned to 533346cc37)