{"record":{"id":"46d9b5098cb90dff","repo":"jdx/mise","slug":"brew-cask-completion-target-already-points-t-46d9b5","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/mod.rs","lineNumber":2710,"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":2692,"sourceCodeEnd":2728,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/cask/mod.rs#L2692-L2728","documentation":"If the completion target already exists as a symlink, mise checks whether it points to (or resolves through, or matches via same_file) something owned by this cask — e.g. the cask's staged completion or an AppDir artifact. If the resolved path belongs to something else, this error is thrown, reporting both what the link currently points to and the owning cask token, preventing silent repointing of a foreign symlink.","triggerScenarios":"The target is a symlink whose `read_link`-resolved path fails all ownership checks: it doesn't match this cask's expected completion source and `file::same_file(&resolved, &source)` is false for every candidate AppDir source.","commonSituations":"The symlink was created by a different cask, an older mise layout, or Homebrew, and still points at an uninstalled or relocated binary; the user hand-created a symlink at the completion path.","solutions":["Inspect `readlink` on the target to see what it points to and decide if that source is still wanted","Remove the stale/foreign symlink and re-run the cask install so mise creates its own link","If the link should be owned by another cask, remove that cask first or adjust its completion target","Update mise if a layout migration left pre-upgrade links unclaimed"],"exampleFix":"// before: symlink points at old Homebrew path\nrm ~/.zsh/completions/_mytool\nmise install <cask>\n// after: mise-owned symlink to the staged completion","handlingStrategy":"try-catch","validationCode":"readlink <target-path>   # confirm the symlink points at this cask's staged file","typeGuard":null,"tryCatchPattern":"match result {\n  Err(e) if e.contains(\"already points to\") && e.contains(\"not owned by cask\") => {\n    eprintln!(\"foreign symlink at target; remove it or repoint the other cask, then reinstall: {e}\");\n  }\n  Err(e) => return Err(e),\n  Ok(v) => v,\n}","preventionTips":["Clean up symlinks from removed casks/package managers before reinstalling","After major upgrades, audit completion dirs for stale links","Avoid hand-creating symlinks in managed completion directories"],"tags":["brew-cask","completions","symlink","ownership-conflict"],"backgroundTag":"file-already-exists","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}