{"record":{"id":"ab44606ed494e96c","repo":"jdx/mise","slug":"err-dotfiles-rollback-failed-rollback-err","errorCode":null,"errorMessage":"{err}\ndotfiles: rollback failed: {rollback_err}","messagePattern":"(.+?)\ndotfiles: rollback failed: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/cli/dotfiles/add.rs","lineNumber":494,"sourceCode":"            if !updated_targets.is_empty() {\n                info!(\"dotfiles: updated {}\", updated_targets.join(\", \"));\n            }\n            if let Some(plan) = apply_plan {\n                apply_started = true;\n                system::files::execute_apply(&config, plan, &apply_opts)?;\n            }\n            Ok(())\n        })();\n        if let Err(err) = result {\n            if let Err(rollback_err) = rollback_add(\n                &source_backups,\n                &target_backups,\n                &mut moved_targets,\n                apply_started,\n                &config_path,\n                original_config.as_deref(),\n            ) {\n                bail!(\"{err}\\ndotfiles: rollback failed: {rollback_err}\");\n            }\n            return Err(err);\n        }\n        Ok(())\n    }\n}\n\n#[derive(Debug)]\nstruct PlannedAdd {\n    target_raw: String,\n    target: PathBuf,\n    source: PathBuf,\n    mode: FileMode,\n    implied_source: bool,\n    explicit_mode: bool,\n    already_managed: Option<FileRequest>,\n}\n","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/dotfiles/add.rs#L476-L512","documentation":"When `mise dot add` fails during apply, it attempts a rollback; if the rollback itself also fails, mise raises a combined error showing the original failure plus `dotfiles: rollback failed: ...`. The system may be left in a partially applied state that the user must repair manually.","triggerScenarios":"An apply-phase error (err) occurs, `rollback_add` runs and returns rollback_err; the code bails with the concatenated message.","commonSituations":"Disk/permission problems that caused the original failure also break rollback (e.g. cannot remove or restore backup files); config file was moved mid-run; crash left stale state.","solutions":["Read both parts of the message; fix the rollback failure cause first (permissions, missing backup paths)","Manually restore targets from the backup locations listed/known to mise (e.g. `.bak` copies created during apply)","Re-create symlinks or copy back originals for the affected dotfiles","Once state is clean, re-run `mise dot add`"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# preflight checks that make both apply and rollback safe\ntest -w \"$(dirname \"$CFG\")\" && df -h \"$(dirname \"$CFG\")\" | tail -1","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"rollback failed\") => {\n        // manual recovery: restore backups, then re-add\n    }\n    ...\n}","preventionTips":["Back up the mise config and dotfiles before large `mise dot add` batches","Don't interrupt `mise dot add` mid-apply","Ensure directories are writable so rollback can complete"],"tags":["dotfiles","rollback","state-corruption"],"backgroundTag":"invalid-state-transition","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"}