{"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":488,"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(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":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/dotfiles/add.rs#L470-L506","documentation":"When the dotfiles add apply step fails, run_inner attempts to roll back all partial changes (restored targets, backups, config file). If any rollback step also fails, the original error and the rollback error are chained into a single bail: `<err>\\ndotfiles: rollback failed: <rollback_err>`. This tells the user that the operation failed AND the automatic restore could not fully undo it, so manual repair may be needed.","triggerScenarios":"Any failure during apply (e.g. copy/symlink errors) combined with a failing rollback action — backup files missing, restore_path errors like permission denied, config restore failing, or leftover moved targets that couldn't be moved back.","commonSituations":"Permissions problems on dotfile paths or backups directory; backups removed/cleaned mid-run; cross-device moves failing during restore; running out of disk space during recovery.","solutions":["Read both parts of the message: fix the rollback error first (usually a permissions or missing-backup issue) so you can manually restore files.","Manually restore affected targets from the backups referenced in the error, or re-create the original files.","Fix the root-cause condition (permissions/disk/same-filesystem source) and re-run `mise bootstrap dotfiles add`."],"exampleFix":"# fix permissions preventing rollback, then retry\nsudo chown -R \"$USER\" ~/.config/backups  # or the path named in the rollback error\nmise bootstrap dotfiles add ~/.zshrc --source ~/dotfiles/zshrc","handlingStrategy":"try-catch","validationCode":"// pre-flight: writable paths, same device, enough space\nimport { accessSync, constants, statfsSync } from 'node:fs';\naccessSync(sourceDir, constants.W_OK);\naccessSync(targetDir, constants.W_OK);\nif (statfsSync(sourceDir).dev !== statfsSync(targetDir).dev) throw new Error('cross-device source');","typeGuard":null,"tryCatchPattern":"try {\n  execSync(`mise bootstrap dotfiles add ${target} --source ${source}`);\n} catch (e) {\n  if (String(e.stderr).includes('rollback failed')) {\n    console.error('Partial apply AND failed rollback: manually restore from backups before retrying.');\n  } else throw e;\n}","preventionTips":["Run add with a writable HOME/config and sufficient disk space.","Never modify dotfile targets or the mise config while an add is running.","Keep backups intact until the command reports success."],"tags":["filesystem","dotfiles","rollback","partial-failure"],"backgroundTag":"invalid-state-transition","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}