{"record":{"id":"a6776e88b17a69f1","repo":"jdx/mise","slug":"cannot-link-to-its-own-install-path","errorCode":null,"errorMessage":"cannot link {} to its own install path","messagePattern":"cannot link (.+?) to its own install path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/link.rs","lineNumber":72,"sourceCode":"                        \"mise link only supports concrete versions and refs, not {}\",\n                        tvr.version()\n                    );\n                }\n                ToolVersion::new(tvr.clone(), version.clone()).tv_pathname()\n            }\n            ToolRequest::Ref { .. } => ToolVersion::new(tvr.clone(), tvr.version()).tv_pathname(),\n            _ => unreachable!(),\n        };\n        let path = self.path.absolutize()?;\n        if !path.exists() {\n            warn!(\n                \"Target path {} does not exist\",\n                style(path.to_string_lossy()).cyan().for_stderr()\n            );\n        }\n        let target = self.tool.ba.installs_path.join(&version_pathname);\n        if !file::is_symlink_to(&target, &path) && file::same_file(&path, &target) {\n            bail!(\"cannot link {} to its own install path\", self.tool.style());\n        }\n        {\n            let _state_lock =\n                install_state::lock_tool_version(&self.tool.ba.short, &version_pathname)?;\n            if !file::is_symlink_to(&target, &path) {\n                if target.exists() {\n                    if self.force {\n                        remove_all(&target)?;\n                    } else {\n                        return Err(eyre!(\n                            \"Tool version {} already exists, use {} to overwrite\",\n                            self.tool.style(),\n                            style(\"--force\").yellow().for_stderr()\n                        ));\n                    }\n                }\n                file::create_dir_all(target.parent().unwrap())?;\n                make_symlink(&path, &target)?;","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/cli/link.rs#L54-L90","documentation":"`mise link` refuses when the source path and the destination (installs/<tool>/<version_pathname>) are the same file (file::same_file, with an exception when the destination is already a correct symlink to it). Creating that link would point a directory at itself, producing a broken/infinite-resolution install entry.","triggerScenarios":"Linking a tool that already lives inside mise's installs tree for the same tool+version, e.g. `mise link node@22.17.1 ~/.local/share/mise/installs/node/22.17.1`; linking after a partial previous link left the real directory at the target path.","commonSituations":"Trying to 'repair' an existing mise-managed install by linking to itself; moving installs around and picking the old canonical path as the link source.","solutions":["Link from a copy or the original location outside mise's installs tree: `cp -r ~/.tools/node-22 ~/.local/share/mise/installs/node/22.17.1-src` then link that","If the version is already correctly installed at the target, no link is needed — `mise use node@22.17.1` directly","Remove the half-finished target directory first (`mise uninstall node@22.17.1` or rm the path), then link from the real source"],"exampleFix":"# before\nmise link node@22.17.1 ~/.local/share/mise/installs/node/22.17.1\n# after\nmise link node@22.17.1 /opt/node-v22.17.1","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nsrc=$(readlink -f \"$1\")\ndst=$(readlink -f \"${MISE_DATA_DIR:-$HOME/.local/share/mise}/installs/$tool/$version_path\")\n[[ \"$src\" == \"$dst\" ]] && { echo \"refusing: source equals target install path\" >&2; exit 2; }\nmise link \"$tool@$version_path\" \"$1\"","typeGuard":null,"tryCatchPattern":"mise link \"$tool@$v\" \"$src\" 2>err.log || { grep -q 'its own install path' err.log && echo \"already installed there; nothing to link\" >&2; }","preventionTips":["Keep custom tool installs outside mise's installs directory before linking them","Verify with realpath that source and destination differ"],"tags":["cli","link","symlink","self-reference","mise"],"backgroundTag":"self-referential-symlink","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}