jdx/mise · error

brew-cask: completion artifact '{}' was not staged

Error message

brew-cask: completion artifact '{}' was not staged

What it means

mise links shell-completion artifacts from a staged cask into the user's completion directories. Before linking, it checks the staged completion file exists at the expected caskroom path; this error is thrown when the completion artifact the cask declared was not present in the staged output.

Source

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

        let caskroom_completion = caskroom_completion_path(caskroom, &target)?;
        if let Some(parent) = caskroom_completion.parent() {
            file::create_dir_all(parent)?;
        }
        let output = generate_completion_output(&executable, completion, *shell)?;
        crate::file::write(caskroom_completion, output)?;
    }
    Ok(())
}

fn link_completion(
    cask: &Cask,
    artifacts: &CaskArtifacts,
    caskroom: &Path,
    target: &Path,
) -> Result<()> {
    let caskroom_completion = caskroom_completion_path(caskroom, target)?;
    if !caskroom_completion.is_file() {
        bail!(
            "brew-cask: completion artifact '{}' was not staged",
            target.display()
        );
    }
    if let Some(parent) = target.parent() {
        create_dir_all_elevating(parent)?;
    }
    ensure_completion_target_replaceable(cask, artifacts, target)?;
    make_symlink_elevating(&caskroom_completion, target)?;
    Ok(())
}

fn ensure_completion_target_replaceable(
    cask: &Cask,
    artifacts: &CaskArtifacts,
    target: &Path,
) -> Result<()> {
    let Ok(metadata) = target.symlink_metadata() else {

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Re-run the cask install to ensure staging completed
  2. Inspect the caskroom directory to see which completions were actually staged and compare with the cask definition
  3. Update mise or the cask so the completion source path matches the upstream layout
  4. Skip/disable the completion artifact if the cask no longer ships one

Example fix

// before: stale caskroom from failed install
rm -rf <caskroom-dir> && mise install <cask>
// after: full stage present, linking succeeds
Defensive patterns

Strategy: validation

Validate before calling

test -f <caskroom>/<cask>/<completion-source> || echo "completion artifact missing from stage"

Try / catch

match result {
  Err(e) if e.contains("completion artifact") && e.contains("was not staged") => {
    eprintln!("staged completion missing; reinstall cask or update its completion stanza: {e}");
  }
  Err(e) => return Err(e),
  Ok(v) => v,
}

Prevention

When it happens

Trigger: The linking routine resolves `caskroom_completion_path(caskroom, target)` and finds `!caskroom_completion.is_file()` — the cask's completion stanza points at a file that staging did not produce or that was removed.

Common situations: Upstream renamed its generated completion file so the cask's declared source no longer exists; an interrupted install left an incomplete stage; the completion lives inside an app bundle that failed to stage.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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