{"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":2862,"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":2844,"sourceCodeEnd":2880,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2844-L2880","documentation":"When unapplying a `file` (copy) entry whose source is missing, mise can only safely remove the target if the target still matches the inline managed content byte-for-byte. If the target is not a symlink and its contents differ from the expected content, the library refuses to delete a file it cannot prove it owns and asks for `--force`.","triggerScenarios":"Unapply planning where `req.source` does not exist, the target exists as a regular file, and `file::read(target) != req.content` — i.e. the user edited the applied copy after installation, or the inline content in config changed.","commonSituations":"A user hand-edited an applied dotfile, then removed the source from their dotfiles repo and tried to unapply; or the config's inline content was updated but never re-applied before removing the source.","solutions":["Re-run with `--force` to remove the modified target anyway","Restore the source file so mise can compare against it again","If the local edits matter, save a copy of the target before unapplying with --force"],"exampleFix":"// before\n$ mise files unapply\nerror: target differs from the managed content, use --force to remove it\n\n// after — after saving any local edits elsewhere\n$ mise files unapply --force","handlingStrategy":"validation","validationCode":"if !source.exists() && target.is_file()\n   && fs::read_to_string(target)? != inline_content {\n   warn(\"target modified locally; unapply will need --force\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not hand-edit files managed by inline content; edit the config source instead","Re-apply after changing inline content before removing the source","Back up modified targets before unapplying with --force"],"tags":["dotfiles","content-mismatch","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"}