{"record":{"id":"0e1ee2c46f8fb170","repo":"jdx/mise","slug":"brew-cask-unresolved-recovery-for-newly-created-t","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.rs","lineNumber":3180,"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\nfn recover_flight_backups() -> Result<()> {\n    let root = flight_recovery_root();\n    recover_flight_backups_in(&root)\n}\n\nfn 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":3162,"sourceCodeEnd":3198,"githubUrl":"https://github.com/jdx/mise/blob/9dcfcaa0dc8747a2577d3270b69bb9d8313b2807/src/system/packages/brew/cask.rs#L3162-L3198","documentation":"The no-backup variant of the pending-recovery check: a previous flight created this target from scratch (no original to preserve, so the record has no backup) and never committed. A leftover record means the target may be a half-written file, so new operations on that target are refused until the pending flight is resolved.","triggerScenarios":"An interrupted install that had just created a new artifact file and died before the recovery record was cleaned up; a recovery pass unable to delete the leftover target.","commonSituations":"Same as the backup variant: crashed or cancelled cask installs leaving both the new file and its recovery record behind.","solutions":["Re-run the same cask command so the recovery pass removes the leftover target and its record","Or delete the leftover target file named in the error plus its *.recovery record, then retry","If the target must be kept, verify the file is intact and clear only the record"],"exampleFix":"# manual cleanup\nrm '/path/in/error/target'\nrm \"${XDG_STATE_HOME:-~/.local/state}/mise/brew-cask/flight-recovery/example.recovery\"","handlingStrategy":"retry","validationCode":"// Detect a pending no-backup flight for this target before operating on it\nlet root = flight_recovery_root();\nif let Ok(entries) = std::fs::read_dir(&root) {\n    for entry in entries.flatten() {\n        let path = entry.path();\n        if path.extension().is_some_and(|e| e == \"recovery\") {\n            if let Ok(body) = std::fs::read_to_string(&path) {\n                if let Ok(record) = serde_json::from_str::<FlightRecoveryRecord>(&body) {\n                    if record.target == target && record.backup.is_none() {\n                        recover_flight_backups()?; // remove leftover target + record\n                    }\n                }\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"match install_cask(&cask) {\n    Err(e) if e.to_string().contains(\"unresolved recovery for newly created target\") => {\n        recover_flight_backups()?;\n        install_cask(&cask)?\n    }\n    other => other?,\n}","preventionTips":["Re-run the interrupted cask command so recovery removes half-written targets","Only delete leftover targets manually after confirming they are garbage","Avoid force-killing installs during artifact writes"],"tags":["brew-cask","recovery","interrupted-install","transaction"],"backgroundTag":"interrupted-operation-recovery","analyzedSha":"9dcfcaa0dc8747a2577d3270b69bb9d8313b2807","analyzedAt":"2026-08-17T14:28:50.624Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}