{"record":{"id":"e66897591b2e5ef6","repo":"jdx/mise","slug":"source-is-missing-use-force-to-remove-the-targe","errorCode":null,"errorMessage":"source is missing; use --force to remove the target","messagePattern":"source is missing; use --force to remove the target","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":2834,"sourceCode":"            plan_single_file(req, opts, &mut paths)?;\n        }\n        FileMode::SymlinkEach => {\n            bail!(\"mode symlink-each requires the source to be a directory\");\n        }\n        FileMode::Template => {\n            if !req.target.exists() && !req.target.is_symlink() {\n                return Ok(None);\n            }\n            if opts.force {\n                paths.insert(req.target.clone(), ());\n            } else if opts.dry_run {\n                // Rendering may execute commands. Keep dry-run inert, matching\n                // apply/status policy, and describe the removal as conditional.\n                paths.insert(req.target.clone(), ());\n                conditional = true;\n            } else {\n                if !req.source.exists() {\n                    bail!(\"source is missing; use --force to remove the target\");\n                }\n                // Rendering may execute user-authored commands. Defer it until\n                // after the complete unapply plan has been confirmed.\n                conditional = true;\n            }\n        }\n    }\n    if paths.is_empty() && !cleanup_empty_dirs && !conditional && !clear_symlink_each_state {\n        Ok(None)\n    } 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    }","sourceCodeStart":2816,"sourceCodeEnd":2852,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/files.rs#L2816-L2852","documentation":"During unapply planning for a template-mode file, the managed source no longer exists, so mise cannot re-render or verify the target content. Removing the target would destroy a file whose managed origin is gone, so the library requires the user to opt in with `--force`, which instructs it to remove the target unconditionally.","triggerScenarios":"Running `mise files unapply` on a template file entry where `req.source` does not exist, `opts.force` is false, and the target still exists (the earlier `!req.target.exists()` early-return did not fire).","commonSituations":"The dotfiles template was deleted from the repo after being applied; a user switches branches removing the template; the source path moved, then the user tries to tear down the applied target file.","solutions":["Re-run with `--force` (e.g. `mise files unapply --force`) to explicitly allow removing the target","Restore the source template from git and re-run unapply without --force","Delete the stale target file manually and remove the config entry"],"exampleFix":"// before\n$ mise files unapply\nerror: source is missing; use --force to remove the target\n\n// after\n$ mise files unapply --force","handlingStrategy":"validation","validationCode":"if !source.exists() && target.exists() {\n    // require explicit user opt-in before removing\n    require_flag(\"--force\");\n}","typeGuard":null,"tryCatchPattern":"// CLI wrapper\nif (err.message.includes('source is missing')) {\n  prompt(`Source gone; remove ${target} anyway? rerun with --force`);\n}","preventionTips":["Run `mise files status` before unapply to spot missing sources","Keep source templates in version control","Never delete dotfile sources without first unapplying"],"tags":["dotfiles","template","missing-source","safety-guard"],"backgroundTag":"file-not-found","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"}