{"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":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/system/files.rs","lineNumber":1614,"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":1596,"sourceCodeEnd":1632,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/files.rs#L1596-L1632","documentation":"Template entries verify their targets by rendering the source file, so the source must exist. If it is gone, verification is impossible and unapply refuses. `--dry-run` stays inert (it marks the removal conditional instead of rendering) and `--force` skips verification entirely.","triggerScenarios":"`unapply` of a `mode = \"template\"` entry where the target exists, `--force` and `--dry-run` are absent, and `!req.source.exists()` — the template file was deleted/moved or its path in mise.toml is a typo.","commonSituations":"Renamed the .tmpl file in the dotfiles repo without updating mise.toml; partial clone of the repo; typo in the source path.","solutions":["Restore the template source or fix its `source` path in mise.toml, then unapply","Use `--force` when you simply want the rendered target gone and verification is unnecessary","Use `--dry-run` first to see the conditional removal plan"],"exampleFix":"# before: template renamed without updating config\n$ ls ~/dotfiles/gitconfig.tmpl\nls: cannot access '~/dotfiles/gitconfig.tmpl': No such file or directory\n$ mise bootstrap dotfiles unapply\nError: source is missing; use --force to remove the target\n\n# after: update the path, then unapply verifies via render\n$ sed -i 's/gitconfig.tmpl/gitconfig.tera/' mise.toml\n$ mise bootstrap dotfiles unapply","handlingStrategy":"validation","validationCode":"# Template sources must exist before an unapply is attempted.\nfor t in ~/dotfiles/*.tmpl ~/dotfiles/*.tera; do\n  [ -e \"$t\" ] || { echo \"missing template source: $t\"; exit 1; }\ndone","typeGuard":"fn is_missing_template_source(err: &miette::Report) -> bool {\n    err.to_string()\n        .starts_with(\"source is missing; use --force to remove the target\")\n}","tryCatchPattern":null,"preventionTips":["Rename template files and their mise.toml references in the same commit","Run `mise bootstrap dotfiles apply --dry-run` after repo reorganizations","Keep template extensions consistent (.tmpl) so globs and greps find them"],"tags":["mise","dotfiles","template","missing-source","unapply"],"backgroundTag":"missing-source-file","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T20:17:18.057Z"}