{"record":{"id":"dad9274037ef2cc0","repo":"jdx/mise","slug":"brew-cask-cannot-adopt-existing-artifact-is-dad927","errorCode":null,"errorMessage":"brew-cask: cannot adopt '{}': existing artifact is not identical to the cask artifact","messagePattern":"brew-cask: cannot adopt '(.+?)': existing artifact is not identical to the cask artifact","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/mod.rs","lineNumber":1020,"sourceCode":"    // only by name relative to that descriptor. Nothing below resolves a\n    // pathname for the application directory, so a post-validation replacement\n    // of any appdir component — even by the same uid — cannot redirect the\n    // copy, rename, removal, permission repair, or quarantine steps.\n    let parent = ensure_trusted_appdir(\n        logical_target\n            .parent()\n            .ok_or_else(|| eyre!(\"brew-cask: app target has no parent directory\"))?,\n    )?;\n    let name = logical_target\n        .file_name()\n        .ok_or_else(|| eyre!(\"brew-cask: app target has no filename\"))?\n        .to_owned();\n    if adopt && exists_at(&parent.fd, &name)? {\n        if verify_adopt {\n            let source_fingerprint = cask_target_fingerprint(&source)?;\n            let target_fingerprint = cask_target_fingerprint(&logical_target)?;\n            if source_fingerprint != target_fingerprint {\n                bail!(\n                    \"brew-cask: cannot adopt '{}': existing artifact is not identical to the cask artifact\",\n                    logical_target.display()\n                );\n            }\n        }\n        return Ok(true);\n    }\n\n    ditto(&source, &caskroom_app)?;\n    // Suffix hashes stay derived from the logical path so temporary and backup\n    // names are stable across runs.\n    let name_hash = crate::hash::hash_to_str(&logical_target.display().to_string());\n    let tmp_name = replace_bundle_extension(&name, &format!(\"mise-tmp-{name_hash}\"));\n    let old_name = replace_bundle_extension(&name, &format!(\"mise-old-{name_hash}\"));\n    remove_all_at(&parent.fd, &tmp_name)?;\n    ditto_into(&caskroom_app, &parent.fd, &tmp_name)?;\n    activate_app_at(\n        &parent,","sourceCodeStart":1002,"sourceCodeEnd":1038,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/cask/mod.rs#L1002-L1038","documentation":"When adopting an existing artifact into a cask-managed location, Homebrew optionally verifies that the on-disk artifact is byte-identical (fingerprint match) to the cask's staged source. If the fingerprints differ it refuses the adoption to avoid clobbering a user-modified or different-version file.","triggerScenarios":"adopt mode with verify_adopt enabled and the target path already exists; `cask_target_fingerprint(source) != cask_target_fingerprint(logical_target)` — the existing file differs from the staged artifact (different version or modified content).","commonSituations":"Users who manually installed/updated an app to a newer version than the cask, then run `brew install --adopt`; files edited in place (license patches, plist tweaks) breaking fingerprint equality.","solutions":["Bring the existing artifact to the same version/content as the cask (re-download or update) and retry with --adopt","Remove or back up the differing existing artifact and install fresh without adopt","Use `--no-adopt`-equivalent flow (skip adoption) if you want to keep the existing artifact untouched"],"exampleFix":"// shell\n# before\nbrew install --adopt iterm2   # existing app is v3.5, cask ships v3.4\n# after\nbrew uninstall --force iterm2 && brew install --adopt iterm2","handlingStrategy":"validation","validationCode":"if exists && cask_target_fingerprint(&source)? != cask_target_fingerprint(&target)? {\n    eprintln!(\"existing artifact differs; adopt will fail — update or remove it first\");\n}","typeGuard":null,"tryCatchPattern":"match install_adopt(req).await {\n    Err(e) if e.to_string().contains(\"not identical to the cask artifact\") => {\n        // back up target, reinstall fresh, or skip adopt\n        Err(e)\n    }\n    r => r,\n}","preventionTips":["Ensure the on-disk app version matches the cask version before adopting","Avoid in-place edits to app bundles you plan to adopt","Compare versions via `brew info` before `--adopt`"],"tags":["brew","cask","adopt","fingerprint"],"backgroundTag":"checksum-mismatch","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}