{"record":{"id":"5a9b12b937c6ab1c","repo":"jdx/mise","slug":"brew-cask-completion-target-already-points-t","errorCode":null,"errorMessage":"brew-cask: completion target '{}' already points to '{}' and is not owned by cask '{}'","messagePattern":"brew-cask: completion target '(.+?)' already points to '(.+?)' and is not owned by cask '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask.rs","lineNumber":4168,"sourceCode":"        );\n    }\n    let link_target = std::fs::read_link(target)?;\n    let resolved = resolve_symlink_target(target, link_target);\n    let token_dir = caskroom_token_dir(&cask.token);\n    if path_starts_with_resolved_root(&resolved, &token_dir) {\n        return Ok(());\n    }\n    for completion in &artifacts.completions {\n        if completion.target_path()? != target {\n            continue;\n        }\n        if let Some(source) = appdir_artifact_source(&completion.source, &artifacts.apps)?\n            && file::same_file(&resolved, &source)\n        {\n            return Ok(());\n        }\n    }\n    bail!(\n        \"brew-cask: completion target '{}' already points to '{}' and is not owned by cask '{}'\",\n        target.display(),\n        resolved.display(),\n        cask.token\n    )\n}\n\nfn find_completion_source(\n    stage: &Path,\n    caskroom: &Path,\n    cask: &Cask,\n    apps: &[AppArtifact],\n    source: &str,\n) -> Result<Option<PathBuf>> {\n    for root in [caskroom, stage] {\n        if let Some(source) = generated_caskroom_artifact(root, cask, source)\n            && source.is_file()\n        {","sourceCodeStart":4150,"sourceCodeEnd":4186,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/packages/brew/cask.rs#L4150-L4186","documentation":"The completion target is a symlink, but it does not belong to this cask: the link resolves outside this cask's caskroom token directory, and it does not point (same-file) at any completion source declared in this cask's artifacts. The installer refuses to retarget a link owned by another origin.","triggerScenarios":"A different cask (different token) already links a completion with the same file name; the user symlinked the completion to a locally built copy; two casks declaring colliding completion target names.","commonSituations":"Stable and dev casks of the same tool both installing completions; a user-managed completions directory; the completion target path changed between cask versions leaving an old link behind.","solutions":["Uninstall the other cask (or remove its link) that owns the completion target","Retarget this cask's completion artifact to a unique file name, for example prefixed with the token","If the existing link is one you created yourself, delete it and let the cask recreate it"],"exampleFix":"# shell - inspect and clear the foreign link\nreadlink ~/.zsh/completions/_myapp   # points outside this cask's caskroom\nrm ~/.zsh/completions/_myapp","handlingStrategy":"validation","validationCode":"// Before install, verify an existing completion link belongs to this cask\nif let Ok(m) = target.symlink_metadata() && m.file_type().is_symlink() {\n    let resolved = resolve_symlink_target(&target, std::fs::read_link(&target)?);\n    if !path_starts_with_resolved_root(&resolved, &caskroom_token_dir(&cask.token)) {\n        return Err(eyre!(\"completion target '{}' owned by another origin\", target.display()));\n    }\n}","typeGuard":null,"tryCatchPattern":"if err.to_string().contains(\"already points to\") && err.to_string().contains(\"not owned by cask\") {\n    // the message names the current link target; uninstall the other owner or remove the link\n}","preventionTips":["Uninstall the previous cask before installing one that links the same completion name","Give dev/stable casks of one tool distinct completion targets","Avoid hand-symlinking completions for cask-managed tools"],"tags":["brew-cask","completion","ownership","symlink"],"backgroundTag":"package-ownership-conflict","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}