{"record":{"id":"3950e34449b5abab","repo":"zeroclaw-labs/zeroclaw","slug":"update-failed-during-swap-e","errorCode":null,"errorMessage":"Update failed during swap: {e}","messagePattern":"Update failed during swap: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/commands/update.rs","lineNumber":283,"sourceCode":"    );\n    if let Err(e) = swap_binary(&main_binary, &current_exe).await {\n        // Rollback\n        ::zeroclaw_log::record!(\n            WARN,\n            ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note)\n                .with_outcome(::zeroclaw_log::EventOutcome::Unknown)\n                .with_attrs(::serde_json::json!({\"error\": format!(\"{}\", e)})),\n            \"Swap failed, rolling back\"\n        );\n        if let Err(rollback_err) = rollback_binary(&backup_path, &current_exe).await {\n            eprintln!(\"CRITICAL: Rollback also failed: {rollback_err}\"); // i18n-exempt: emergency operator recovery diagnostic, must be unambiguous\n            eprintln!(\n                \"Manual recovery: cp {} {}\",\n                backup_path.display(),\n                current_exe.display()\n            );\n        }\n        bail!(\"Update failed during swap: {e}\");\n    }\n\n    // Phase 6: Smoke test\n    ::zeroclaw_log::record!(\n        INFO,\n        ::zeroclaw_log::Event::new(module_path!(), ::zeroclaw_log::Action::Note),\n        \"Phase 6/6: Smoke test...\"\n    );\n    match smoke_test(&current_exe).await {\n        Ok(()) => {\n            // Cleanup backup on success\n            let _ = tokio::fs::remove_file(&backup_path).await;\n            // Install everything else the archive shipped (the `zerocode`\n            // companion, the `web/dist` dashboard bundle, …). Best-effort:\n            // the validated main binary is already in place and must not be\n            // rolled back if these fail.\n            install_companion_artifacts(&staging, &current_exe, &host_dashboard_candidates()).await;\n            println!(\"{}\", update_success_message(&update_info.latest_version));","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/src/commands/update.rs#L265-L301","documentation":"Error \"Update failed during swap: {e}\" thrown in zeroclaw-labs/zeroclaw.","triggerScenarios":"Thrown at src/commands/update.rs:283 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the swap error (permissions, busy binary, disk space), fix it, and re-run the update.","Re-run `zeroclaw update`; the previous binary is preserved so a failed swap can be retried safely."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}