{"record":{"id":"f5039bb8284bf9ff","repo":"jdx/mise","slug":"differs-from-its-managed-source-use-force-to","errorCode":null,"errorMessage":"{} differs from its managed source; use --force to remove it","messagePattern":"(.+?) differs from its managed source; use --force to remove it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2915,"sourceCode":"    } else {\n        bail!(\n            \"cannot verify {}; use --force to remove it\",\n            target.display_user()\n        )\n    }\n}\n\nfn plan_expected_content(\n    expected: &[u8],\n    target: &Path,\n    force: bool,\n    paths: &mut IndexMap<PathBuf, ()>,\n) -> Result<()> {\n    if force || (target.is_file() && !target.is_symlink() && file::read(target)? == expected) {\n        paths.insert(target.to_path_buf(), ());\n        Ok(())\n    } else {\n        bail!(\n            \"{} differs from its managed source; use --force to remove it\",\n            target.display_user()\n        )\n    }\n}\n\n/// All symlinks under a symlink-each target that point exactly where this\n/// entry maps that relative path. Unlike stale-link pruning this includes\n/// both current and deleted source files because unapply removes the entry's\n/// complete observable footprint.\nfn legacy_owned_links(req: &FileRequest) -> Result<Vec<PathBuf>> {\n    if !req.target.is_dir() || req.target.is_symlink() {\n        return Ok(vec![]);\n    }\n    let mut out = vec![];\n    for entry in walkdir::WalkDir::new(&req.target).sort_by_file_name() {\n        let entry = match entry {\n            Ok(entry) => entry,","sourceCodeStart":2897,"sourceCodeEnd":2933,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2897-L2933","documentation":"Final content-verification step of unapply planning: the target is removed only if `force` is set or the target is a plain file whose bytes equal the expected managed content. Otherwise the library bails, stating the target differs from its managed source, to avoid deleting files the user modified.","triggerScenarios":"Unapply where the target exists but `file::read(target) != expected` and `force` is false — e.g. the target was edited after apply, or has drifted due to another tool rewriting it.","commonSituations":"A user edits an applied dotfile, or an installer/tool rewrites the file, then `mise files unapply` refuses to remove the drifted file.","solutions":["Re-run with `--force` to remove the modified target","Reset the target to the managed content (re-apply first) and then unapply","Preserve local changes: copy the target aside before using --force"],"exampleFix":"// before\n$ mise files unapply\nerror: /home/u/.gitconfig differs from its managed source; use --force to remove it\n\n// after\n$ mise files unapply --force","handlingStrategy":"validation","validationCode":"if fs::read(target)? != expected_content {\n    warn(\"target drifted from managed content; unapply will require --force\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat applied targets as read-only; edit sources and re-apply","Run `mise files status` to detect drift before unapply","Exclude mise-managed paths from other tools that rewrite configs"],"tags":["dotfiles","content-drift","safety-guard"],"backgroundTag":"checksum-mismatch","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"}