{"record":{"id":"1ad82e33ce786976","repo":"jdx/mise","slug":"target-differs-from-the-managed-content-use-for","errorCode":null,"errorMessage":"target differs from the managed content, use --force to remove it","messagePattern":"target differs from the managed content, use --force to remove it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2614,"sourceCode":"    } else {\n        Ok(Some(UnapplyPlan {\n            req,\n            paths: paths.into_keys().collect(),\n            cleanup_empty_dirs,\n            conditional,\n            clear_symlink_each_state,\n        }))\n    }\n}\n\nfn plan_inline_file(req: &FileRequest, paths: &mut IndexMap<PathBuf, ()>) -> Result<()> {\n    if !req.target.is_symlink()\n        && req.target.is_file()\n        && file::read(&req.target)? == req.content.as_deref().expect(\"inline content\").as_bytes()\n    {\n        paths.insert(req.target.clone(), ());\n    } else if req.target.exists() || req.target.is_symlink() {\n        bail!(\"target differs from the managed content, use --force to remove it\");\n    }\n    Ok(())\n}\n\nfn plan_single_file(\n    req: &FileRequest,\n    opts: &UnapplyOpts,\n    paths: &mut IndexMap<PathBuf, ()>,\n) -> Result<()> {\n    if !req.source.exists() && req.target.exists() && !opts.force {\n        bail!(\"source is missing; use --force to remove the target\");\n    }\n    if opts.force && (req.target.exists() || req.target.is_symlink()) {\n        paths.insert(req.target.clone(), ());\n    } else if req.source.exists() {\n        plan_regular_file(&req.source, &req.target, false, paths)?;\n    }\n    Ok(())","sourceCodeStart":2596,"sourceCodeEnd":2632,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/files.rs#L2596-L2632","documentation":"At src/system/files.rs:2614 (inline-content planning in plan_expected_content), mise will remove a target without --force only when it is a regular file exactly matching the managed inline content. If the target exists (or is a symlink) but differs from that content, mise bails to avoid deleting user-modified data.","triggerScenarios":"`mise bootstrap dotfiles unapply` on an entry with inline content where the target exists but is a symlink, or a file whose bytes differ from req.content, and opts.force is false.","commonSituations":"The user edited the managed file locally; another tool rewrote it; or a symlink was placed at the target pointing elsewhere after the entry was applied.","solutions":["Rerun unapply with --force to remove the modified target anyway","Back up the differing file, then rerun with --force","Compare contents (diff/cmp) to confirm the changes are disposable before forcing","Update the inline content in mise.toml if you intend to keep applying modified content"],"exampleFix":"# before\nmise bootstrap dotfiles unapply\n# error: target differs from the managed content, use --force to remove it\n\n# after (after backing up)\ncp ~/.gitignore ~/.gitignore.bak && mise bootstrap dotfiles unapply --force","handlingStrategy":"validation","validationCode":"if (fs.existsSync(entry.target) &&\n    fs.readFileSync(entry.target).toString() !== entry.content) {\n  console.warn(`${entry.target} was modified locally; unapply will need --force`);\n}","typeGuard":"function matchesManagedContent(entry) {\n  try { return fs.readFileSync(entry.target).toString() === entry.content; }\n  catch { return false; }\n}","tryCatchPattern":"try {\n  await unapply(plan);\n} catch (e) {\n  if (String(e).includes('target differs from the managed content')) {\n    backup(entry.target);\n    await unapply({ ...plan, force: true });\n  } else throw e;\n}","preventionTips":["Avoid editing files applied from inline content directly","Diff managed targets against their content before unapplying","Keep inline content in mise.toml updated to include intentional 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"}