jdx/mise · error

artifact target is now claimed by another cask

Error message

artifact target is now claimed by another cask: {}

What it means

Before pruning (deleting) a mise-managed cask's artifacts, mise re-checks that every target path in the candidate's receipt is still claimed only by that cask. If another cask's claim now covers the same path — a target was reassigned or two casks overlap — pruning would delete an artifact belonging to someone else, so the operation aborts.

Solutions

  1. Run the prune again after Homebrew state is consistent; claims are recomputed each time, so a resolved overlap clears the error.
  2. Identify the conflicting casks (`brew list --cask`) and uninstall or prune the correct one explicitly.
  3. Update Homebrew and reinstall the affected casks so receipts no longer share target paths.

Example fix

// before: two tokens claim the same target
claims: "/Applications/Foo.app" -> ["foo", "foo-beta"]
$ mise pkg prune cask:foo   # ERROR: claimed by another cask

// after: remove the duplicate cask first
$ brew uninstall --cask foo-beta
$ mise pkg prune cask:foo   # ok
Defensive patterns

Strategy: try-catch

Validate before calling

// before pruning, check no other token claims the same targets
for target in &receipt.targets {
    if let Some(tokens) = claims.get(&target.path) {
        if tokens.iter().any(|t| t != token) { /* resolve conflict first */ }
    }
}

Try / catch

match result {
    Err(e) if e.to_string().contains("claimed by another cask") => {
        // inspect brew list --cask, resolve overlap, then re-prune
        resolve_overlapping_casks()?; retry()
    }
    r => r,
}

Prevention

When it happens

Trigger: validate_cask_prune_claims, called from apply_cask_prune_plan_in during a cask prune, finds a path in candidate.receipt.targets mapped in `claims` to a token different from candidate.token.

Common situations: Two casks install overlapping artifacts (shared frameworks/helpers); Homebrew migrated an app to a different token and the receipts now collide; a stale receipt for an old token claims a path now owned by a new cask.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at src/system/packages/brew/cask/state.rs:1021

            let version = version?;
            if !version.file_type()?.is_dir()
                || version.file_name().to_string_lossy().starts_with('.')
            {
                continue;
            }
            if let Some(receipt) = read_receipt(&version.path())? {
                for target in receipt.targets {
                    claims.entry(target.path).or_default().insert(token.clone());
                }
            }
        }
    }
    for target in &candidate.receipt.targets {
        if claims
            .get(&target.path)
            .is_some_and(|tokens| tokens.iter().any(|token| token != &candidate.token))
        {
            bail!(
                "artifact target is now claimed by another cask: {}",
                target.path.display()
            );
        }
    }
    Ok(())
}

pub(super) fn validate_cask_prune_candidate(candidate: &CaskPruneCandidate) -> Result<()> {
    if homebrew_metadata_present(&candidate.token)? {
        bail!("Homebrew now owns this cask");
    }
    let receipt = &candidate.receipt;
    if read_receipt(&candidate.version_dir)?.as_ref() != Some(receipt) {
        bail!("ownership receipt has changed");
    }
    if receipt.schema_version != 3 || !receipt.prune_safe || !receipt.pkg_ids.is_empty() {
        bail!("receipt is not marked safe for direct-artifact pruning");

View on GitHub (pinned to 533346cc37)