{"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":2667,"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":2649,"sourceCodeEnd":2685,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/files.rs#L2649-L2685","documentation":"In plan_expected_content (src/system/files.rs:2667), mise removes a target without --force only when the target is a regular, non-symlink file whose content byte-matches the managed source content. Any divergence (or a symlinked target) requires an explicit --force, preventing silent deletion of user-modified files.","triggerScenarios":"`mise bootstrap dotfiles unapply` (or plan_regular_file via it) where the target file's content differs from the expected bytes read from the source, or the target is a symlink, and opts.force is false.","commonSituations":"User edited the applied dotfile (e.g. customized .zshrc); a package manager or another sync tool rewrote the file; the source was updated after apply so contents no longer match.","solutions":["Rerun unapply with --force once you've backed up the modified target","Diff the target against the managed source to review local changes before forcing","Re-copy the managed source over the target to restore exact content, then unapply without --force","Update the source content in the dotfiles store to include the local changes"],"exampleFix":"# before\nmise bootstrap dotfiles unapply\n# error: ~/.zshrc differs from its managed source; use --force to remove it\n\n# after\ndiff ~/.config/mise/dotfiles/zshrc ~/.zshrc  # review\ncp ~/.zshrc ~/zshrc.local-changes.bak\nmise bootstrap dotfiles unapply --force","handlingStrategy":"validation","validationCode":"const expected = fs.readFileSync(entry.source);\nconst actual = fs.readFileSync(entry.target);\nif (!actual.equals(expected)) {\n  console.warn(`${entry.target} differs from managed source; unapply will need --force`);\n}","typeGuard":"function contentMatches(source, target) {\n  try { return fs.readFileSync(target).equals(fs.readFileSync(source)); }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  await unapply(plan);\n} catch (e) {\n  if (String(e).includes('differs from its managed source')) {\n    backup(entry.target);\n    await unapply({ ...plan, force: true });\n  } else throw e;\n}","preventionTips":["Don't hand-edit applied dotfiles; edit the managed source and reapply","Run diff/status before unapply to catch local modifications","Update the managed source when adopting local changes"],"tags":["dotfiles","filesystem","content-mismatch","force-flag"],"backgroundTag":"requires-force-flag","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}