{"record":{"id":"c24905f7b272248a","repo":"jdx/mise","slug":"target-is-not-the-managed-symlink-use-force-to","errorCode":null,"errorMessage":"target is not the managed symlink, use --force to remove it","messagePattern":"target is not the managed symlink, use --force to remove it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2757,"sourceCode":"        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 {\n                    bail!(\"target is not the managed directory, use --force to remove it\");\n                }\n            } else if req.target.is_dir() {\n                for path in owned_links(req)? {\n                    paths.insert(path, ());\n                }\n                cleanup_empty_dirs = true;\n            }\n        }","sourceCodeStart":2739,"sourceCodeEnd":2775,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2739-L2775","documentation":"Unapply planning for symlink-mode entries: the target exists but is NOT a symlink (a regular file or other object sits where mise would have placed its symlink). Mise cannot prove the target is its own, so it refuses to delete it without `--force`.","triggerScenarios":"`mise dot unapply` on a symlink entry where the target path was replaced by a regular file — e.g. the user copied the dotfile content into a real file, or another tool wrote the file — while `--force` was not given.","commonSituations":"A dotfile manager migration (e.g. from stow or chezmoi) replaced symlinks with real files; user ran an editor/tool that materialized the file; `mode` was changed from copy to symlink in config after applying.","solutions":["Verify the target's content; if it is your own file, remove it manually and re-run unapply.","Back it up (`mv <target> <target>.bak`) then re-run `mise dot unapply`.","Use `mise dot unapply --force` if you accept deleting the non-managed file."],"exampleFix":"// before: ~/.gitconfig is a regular file but entry is mode=symlink\nmv ~/.gitconfig ~/.gitconfig.bak\nmise dot unapply   # succeeds, then optionally restore/apply","handlingStrategy":"validation","validationCode":"[ -L ~/.gitconfig ] || echo 'target is not a symlink; unapply will need --force or manual removal'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat managed symlink targets as owned by mise; don't materialize them into real files.","When migrating from another dotfile manager, clean up its artifacts first.","Keep entry `mode` consistent with how the entry was originally applied."],"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"}