{"record":{"id":"5281b3162d7a5656","repo":"jdx/mise","slug":"artifact-target-is-now-claimed-by-another-cask-5281b3","errorCode":null,"errorMessage":"artifact target is now claimed by another cask: {}","messagePattern":"artifact target is now claimed by another cask: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/state.rs","lineNumber":1021,"sourceCode":"            let version = version?;\n            if !version.file_type()?.is_dir()\n                || version.file_name().to_string_lossy().starts_with('.')\n            {\n                continue;\n            }\n            if let Some(receipt) = read_receipt(&version.path())? {\n                for target in receipt.targets {\n                    claims.entry(target.path).or_default().insert(token.clone());\n                }\n            }\n        }\n    }\n    for target in &candidate.receipt.targets {\n        if claims\n            .get(&target.path)\n            .is_some_and(|tokens| tokens.iter().any(|token| token != &candidate.token))\n        {\n            bail!(\n                \"artifact target is now claimed by another cask: {}\",\n                target.path.display()\n            );\n        }\n    }\n    Ok(())\n}\n\npub(super) fn validate_cask_prune_candidate(candidate: &CaskPruneCandidate) -> Result<()> {\n    if homebrew_metadata_present(&candidate.token)? {\n        bail!(\"Homebrew now owns this cask\");\n    }\n    let receipt = &candidate.receipt;\n    if read_receipt(&candidate.version_dir)?.as_ref() != Some(receipt) {\n        bail!(\"ownership receipt has changed\");\n    }\n    if receipt.schema_version != 3 || !receipt.prune_safe || !receipt.pkg_ids.is_empty() {\n        bail!(\"receipt is not marked safe for direct-artifact pruning\");","sourceCodeStart":1003,"sourceCodeEnd":1039,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/cask/state.rs#L1003-L1039","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the prune again after Homebrew state is consistent; claims are recomputed each time, so a resolved overlap clears the error.","Identify the conflicting casks (`brew list --cask`) and uninstall or prune the correct one explicitly.","Update Homebrew and reinstall the affected casks so receipts no longer share target paths."],"exampleFix":"// before: two tokens claim the same target\nclaims: \"/Applications/Foo.app\" -> [\"foo\", \"foo-beta\"]\n$ mise pkg prune cask:foo   # ERROR: claimed by another cask\n\n// after: remove the duplicate cask first\n$ brew uninstall --cask foo-beta\n$ mise pkg prune cask:foo   # ok","handlingStrategy":"try-catch","validationCode":"// before pruning, check no other token claims the same targets\nfor target in &receipt.targets {\n    if let Some(tokens) = claims.get(&target.path) {\n        if tokens.iter().any(|t| t != token) { /* resolve conflict first */ }\n    }\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"claimed by another cask\") => {\n        // inspect brew list --cask, resolve overlap, then re-prune\n        resolve_overlapping_casks()?; retry()\n    }\n    r => r,\n}","preventionTips":["Avoid installing duplicate/renamed casks that share artifacts (foo + foo-beta).","Keep Homebrew and mise receipts in sync; prune only after brew state settles.","Review `brew list --cask` for overlapping tokens before scripted prunes."],"tags":["cask","prune","ownership","conflict"],"backgroundTag":"invalid-state-transition","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}