{"record":{"id":"ebf08aecb0ee1ae5","repo":"jdx/mise","slug":"target-symlink-points-to-use-force-to-remove","errorCode":null,"errorMessage":"target symlink points to {}, use --force to remove it","messagePattern":"target symlink points to (.+?), use --force to remove it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2748,"sourceCode":"    let mut paths = IndexMap::<PathBuf, ()>::new();\n    let mut cleanup_empty_dirs = false;\n    let mut conditional = false;\n    let mut clear_symlink_each_state = false;\n    match req.mode {\n        // A Windows file link that came out as a copy is planned by content further down; one\n        // that is a real symlink belongs here, where the link target is what identifies it as\n        // ours. `plan_expected_content` requires a non-symlink, so routing a symlink there\n        // would make unapply demand `--force`.\n        FileMode::Symlink\n            if !(cfg!(windows) && req.source.is_file() && !req.target.is_symlink()) =>\n        {\n            if req.target.is_symlink() {\n                let dest = std::fs::read_link(&req.target)?;\n                if opts.force || dest == req.source || points_at_same_file(&req.target, &req.source)\n                {\n                    paths.insert(req.target.clone(), ());\n                } else {\n                    bail!(\n                        \"target symlink points to {}, use --force to remove it\",\n                        dest.display_user()\n                    );\n                }\n            } else if req.target.exists() {\n                if opts.force {\n                    paths.insert(req.target.clone(), ());\n                } else {\n                    bail!(\"target is not the managed symlink, use --force to remove it\");\n                }\n            }\n        }\n        FileMode::SymlinkEach if !cfg!(windows) => {\n            clear_symlink_each_state = symlink_each_state_path(req).exists();\n            if req.target.is_symlink() || (req.target.exists() && !req.target.is_dir()) {\n                if opts.force {\n                    paths.insert(req.target.clone(), ());\n                } else {","sourceCodeStart":2730,"sourceCodeEnd":2766,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2730-L2766","documentation":"During `mise dot unapply` planning for symlink-mode entries, the target IS a symlink but its destination differs from the configured source. Because the link cannot be proven to be mise-owned, removing it could destroy a user-created link, so mise refuses and requires explicit `--force`.","triggerScenarios":"`mise dot unapply` on a `[dotfiles]` symlink entry whose target symlink resolves to a path other than the configured source (and does not point at the same underlying file), without `--force`.","commonSituations":"The dotfiles repo was moved or re-cloned to a new path, so the link's recorded destination no longer equals the new source path; the user manually re-pointed the symlink; config `source` was edited after applying.","solutions":["Check where the link points (`readlink <target>`); if it is your own link, remove it manually.","Update the `[dotfiles]` source path in config to match the link's actual destination, then unapply without force.","Re-apply first (`mise dot apply`) so the link is re-created from the current source, then unapply.","Use `mise dot unapply --force` if you are certain the symlink is safe to remove."],"exampleFix":"// before: repo moved from ~/dotfiles to ~/repos/dotfiles\n// after: fix config source, then\n# [dotfiles].\"~/.zshrc\"\n# source = \"~/repos/dotfiles/zshrc\"\nmise dot unapply","handlingStrategy":"validation","validationCode":"dest=$(readlink ~/.zshrc); [ \"$dest\" = \"$HOME/dotfiles/zshrc\" ] || echo \"unexpected symlink dest: $dest\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never re-point managed symlinks by hand; change config and re-apply.","Keep the dotfiles repo at a stable path (or update config immediately after a move).","Check `readlink` output of managed targets after repo relocations."],"tags":["dotfiles","symlink","unapply"],"backgroundTag":"invalid-argument-value","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"}