{"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":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2767,"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":2749,"sourceCodeEnd":2785,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2749-L2785","documentation":"Unapply planning for directory `symlink-each` entries: the target is expected to be a directory whose children are managed symlinks, but the target is itself a symlink or a non-directory file. Mise cannot enumerate owned children, so without `--force` it refuses to remove the object.","triggerScenarios":"`mise dot unapply` on a `mode = \"symlink-each\"` entry whose target path is a symlink or regular file instead of a directory (e.g. the user applied the entry earlier with `mode = \"symlink\"`, then changed the config to symlink-each).","commonSituations":"Config mode migrated between symlink and symlink-each after applying; user replaced the target directory with a symlink to elsewhere; another tool took over the path.","solutions":["Inspect the target (`ls -la <target>`); if it is a link you own, remove it manually and re-run.","Align the config `mode` with what was actually applied (back to symlink), unapply, then switch modes.","Use `mise dot unapply --force` once certain the object is disposable."],"exampleFix":"// before: target ~/.config/nvim is a symlink but entry uses mode=\"symlink-each\"\n# temporarily set mode = \"symlink\" in [dotfiles].\"~/.config/nvim\"\nmise dot unapply\n# then restore mode = \"symlink-each\"","handlingStrategy":"validation","validationCode":"[ -d ~/.config/nvim ] && [ ! -L ~/.config/nvim ] || echo 'symlink-each target must be a real directory'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Change `mode` in config only after unapplying the entry with its current mode.","Don't replace managed target directories with symlinks manually.","Audit targets with `ls -la` before switching between symlink and symlink-each."],"tags":["dotfiles","symlink-each","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"}