{"record":{"id":"27a113f1e53e0415","repo":"jdx/mise","slug":"target-is-not-the-managed-directory-use-force-t","errorCode":null,"errorMessage":"target is not the managed directory, use --force to remove it","messagePattern":"target is not the managed directory, use --force to remove it","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":1556,"sourceCode":"                        \"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        }\n        FileMode::Copy | FileMode::SymlinkEach if req.source.is_dir() => {\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 (source, target) in walk_source_files(req)? {\n                    plan_regular_file(&source, &target, opts.force, &mut paths)?;","sourceCodeStart":1538,"sourceCodeEnd":1574,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/files.rs#L1538-L1574","documentation":"For `symlink-each` entries (mise recreates the source directory's structure under the target and symlinks each file individually), the target must be a real directory that mise seeded. If the target itself is a symlink or an existing non-directory file, mise cannot enumerate owned children and refuses removal without `--force`.","triggerScenarios":"`unapply` of a `mode = \"symlink-each\"` entry (non-Windows) where `req.target.is_symlink()` or the target exists and is not a directory — e.g. ~/.config/foo was replaced by a symlink to a dotfiles checkout, or turned into a file.","commonSituations":"User replaced the target directory with a symlink to save space; the directory was converted to a file; entry mode changed from symlink to symlink-each without re-apply.","solutions":["Restore the target to a plain directory (remove the replacement, `mkdir`), re-apply, then unapply","Use `--force` if the replacement symlink/file is disposable","Fix the entry's mode/source in mise.toml if it was misdeclared for this target"],"exampleFix":"# before: ~/.config/ghostty was replaced by a symlink\n$ ls -ld ~/.config/ghostty\nlrwxrwxrwx 1 me me 22 ~/.config/ghostty -> /home/me/dotfiles/ghostty\n$ mise bootstrap dotfiles unapply\nError: target is not the managed directory, use --force to remove it\n\n# after: keep the checkout elsewhere, restore a real dir, re-apply, unapply\n$ rm ~/.config/ghostty && mkdir ~/.config/ghostty\n$ mise bootstrap dotfiles apply && mise bootstrap dotfiles unapply","handlingStrategy":"validation","validationCode":"# symlink-each targets must be plain directories.\n[ -L ~/.config/ghostty ] && { echo 'target is a symlink'; exit 1; }\n[ -e ~/.config/ghostty ] && [ ! -d ~/.config/ghostty ] && { echo 'target not a dir'; exit 1; }","typeGuard":"fn is_not_managed_dir(err: &miette::Report) -> bool {\n    err.to_string()\n        .starts_with(\"target is not the managed directory\")\n}","tryCatchPattern":null,"preventionTips":["Never replace symlink-each target directories with links; add an ignore entry instead","Run `mise bootstrap dotfiles status` after manual target surgery","Prefer `symlink` mode for whole-directory dotfiles when you do not need foreign files inside the target"],"tags":["mise","dotfiles","symlink-each","directory","unapply"],"backgroundTag":"unexpected-file-type","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}