{"record":{"id":"c87cbfe453d099e4","repo":"jdx/mise","slug":"brew-cask-unresolved-recovery-for-newly-created-t-c87cbf","errorCode":null,"errorMessage":"brew-cask: unresolved recovery for newly created target {}","messagePattern":"brew-cask: unresolved recovery for newly created target (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/flight.rs","lineNumber":398,"sourceCode":"            .is_none_or(|extension| extension != \"recovery\")\n        {\n            continue;\n        }\n        let Ok(body) = file::read_to_string(&path) else {\n            continue;\n        };\n        let Ok(record) = serde_json::from_str::<FlightRecoveryRecord>(&body) else {\n            continue;\n        };\n        if record.target == target {\n            if let Some(backup) = record.backup {\n                bail!(\n                    \"brew-cask: unresolved recovery for {} still preserves its original at {}\",\n                    target.display(),\n                    backup.display()\n                );\n            }\n            bail!(\n                \"brew-cask: unresolved recovery for newly created target {}\",\n                target.display()\n            );\n        }\n    }\n    Ok(())\n}\n\npub(super) fn recover_flight_backups() -> Result<()> {\n    let root = flight_recovery_root();\n    recover_flight_backups_in(&root)\n}\n\npub(super) fn recover_flight_backups_in(root: &Path) -> Result<()> {\n    let Ok(entries) = std::fs::read_dir(root) else {\n        return Ok(());\n    };\n    for entry in entries {","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/cask/flight.rs#L380-L416","documentation":"Companion to the backup-case recovery error: when a flight transaction created a target that didn't exist before, the recovery record has no backup. If such a record still exists for this target, a previous run crashed after creating the target but before committing, and mise refuses to touch the target to avoid destroying a possibly-user-created file. The stale target must be resolved (recovered or removed) first.","triggerScenarios":"protect_with_elevation → ensure_no_unresolved_flight_recovery finds a *.recovery record whose target matches and whose backup field is None (an 'absent-*' record) — a prior run died between creating the new target and finishing the transaction.","commonSituations":"Interrupted first-time install of a cask app (no previous version to back up); a crashed run left the newly linked app in place; concurrent mise runs racing on the same app target.","solutions":["Re-run the install so recover_flight_backups can evaluate the target (via receipt claim) and clear the record.","If the target is a leftover from the crashed run and you don't need it, delete it manually, then remove the corresponding absent-*.recovery file in mise's brew-cask/flight-recovery state dir.","If the target is user data you created, keep it and remove the stale recovery record after confirming no install is in progress.","Avoid running two mise cask operations on the same app simultaneously."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// resolve the stale 'newly created' target before reinstalling\nmatch install_cask(token) {\n    Err(e) if e.to_string().contains(\"unresolved recovery for newly created target\") => {\n        // inspect the target path in the message; delete if it is a crash leftover,\n        // then remove the absent-*.recovery record and retry\n        retry(install_cask(token))\n    }\n    other => other,\n}","preventionTips":["Let interrupted installs complete recovery on the next run before starting new ones.","Check mise state (brew-cask/flight-recovery) for stale records after a crash.","Serialize cask operations that touch the same /Applications target."],"tags":["brew","recovery","interrupted-transaction","state"],"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"}