{"record":{"id":"09cfa5d077ce3325","repo":"lbjlaq/Antigravity-Manager","slug":"brew-upgrade-failed","errorCode":"brew_upgrade_failed","errorMessage":"brew_upgrade_failed","messagePattern":"brew_upgrade_failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/modules/update_checker.rs","lineNumber":543,"sourceCode":"            logger::log_error(\"Homebrew upgrade timed out after 3 minutes\");\n            return Err(\"brew_timeout\".to_string());\n        }\n    };\n\n    let stdout = String::from_utf8_lossy(&output.stdout).to_string();\n    let stderr = String::from_utf8_lossy(&output.stderr).to_string();\n\n    if output.status.success() {\n        logger::log_info(&format!(\"Homebrew upgrade succeeded: {}\", stdout));\n        Ok(stdout)\n    } else {\n        logger::log_error(&format!(\n            \"brew upgrade failed - stdout: {} stderr: {}\",\n            stdout, stderr\n        ));\n        // Return structured error key for frontend i18n\n        if stderr.contains(\"already installed\") || stdout.contains(\"already installed\") {\n            Err(\"brew_already_latest\".to_string())\n        } else {\n            Err(\"brew_upgrade_failed\".to_string())\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn test_compare_versions() {\n        assert!(compare_versions(\"3.3.36\", \"3.3.35\"));\n        assert!(compare_versions(\"3.4.0\", \"3.3.35\"));\n        assert!(compare_versions(\"4.0.3\", \"3.3.35\"));\n        assert!(!compare_versions(\"3.3.34\", \"3.3.35\"));\n        assert!(!compare_versions(\"3.3.35\", \"3.3.35\"));\n    }","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/lbjlaq/Antigravity-Manager/blob/90a2b6b20797e2e593a83d0c54ab86037863fe70/src-tauri/src/modules/update_checker.rs#L525-L561","documentation":"Generic failure branch of brew_upgrade_cask (src-tauri/src/modules/update_checker.rs): when `brew upgrade --cask antigravity-tools` exits with a non-success status and the output does NOT contain \"already installed\", the command returns 'brew_upgrade_failed' as a structured i18n key, having logged full stdout/stderr. This covers any real brew failure — cask definition errors, checksum mismatches, permission problems moving the app bundle, tap issues, or network download failures.","triggerScenarios":"The spawned brew process completes with a non-zero exit code whose stdout/stderr lacks \"already installed\" — e.g. cask staging failed, SHA256 checksum verification failed, /Applications write permission denied (app running or owned by root), cask was disabled/renamed, or the download failed mid-transfer.","commonSituations":"The app being upgraded is currently running so brew cannot move it into /Applications; Homebrew cask definition broken after a vendor release changed the artifact/checksum; partially migrated Homebrew ownership (files owned by root after a sudo misuse); interrupted downloads leaving a corrupt cache in ~/Library/Caches/Homebrew; cask removed or renamed in homebrew/cask.","solutions":["Read the detailed log line 'brew upgrade failed - stdout: ... stderr: ...' (update_checker.rs:537-540) — it contains brew's actual error; fix the root cause it names.","Quit the antigravity-tools app completely and retry, since a running app commonly blocks cask staging into /Applications.","Refresh state then retry manually: `brew update && brew upgrade --cask antigravity-tools`; if checksum fails, run `brew cleanup` and retry to clear a corrupt download cache.","Fix permissions if brew reports them: ensure ~/Library/Caches/Homebrew and /Applications are writable by your user; avoid running brew with sudo (chown -R $(whoami) the reported paths).","If the cask itself is broken or disabled, install the new version directly from the vendor, or `brew uninstall --cask antigravity-tools && brew install --cask antigravity-tools` once the cask is fixed."],"exampleFix":"// before: app running blocks upgrade -> brew_upgrade_failed\nbrew upgrade --cask antigravity-tools  // Error: It seems the App source ... is already at /Applications\n// after: quit the app first\nosascript -e 'quit app \"antigravity-tools\"'\nbrew upgrade --cask antigravity-tools  // succeeds","handlingStrategy":"try-catch","validationCode":"// Pre-flight: ensure the app isn't running and brew taps are fresh before upgrading\nconst { exec } = require('child_process');\nexec('pgrep -x antigravity-tools', (err, stdout) => {\n  if (stdout && stdout.trim()) console.warn('quit the app before brew upgrade to avoid staging failure');\n});\nexec('brew update', () => console.log('taps refreshed'));","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('brew_upgrade_cask');\n} catch (e) {\n  if (e === 'brew_upgrade_failed') {\n    // fetch the detailed stdout/stderr from the app log\n    // ('brew upgrade failed - stdout: ... stderr: ...') and act on the root cause\n    openLogAndDiagnose();\n  } else throw e;\n}","preventionTips":["Always quit the running app before a cask upgrade; running apps block staging into /Applications.","Run brew update regularly so cask definitions and checksums are current.","Never run brew with sudo; keep Homebrew paths owned by your user to avoid permission failures.","Run `brew cleanup` after failed upgrades to drop corrupt cached downloads.","Read the logged stdout/stderr pair — it contains brew's precise failure reason."],"tags":["homebrew","macos","update","process"],"backgroundTag":"brew-upgrade-failed","analyzedSha":"90a2b6b20797e2e593a83d0c54ab86037863fe70","analyzedAt":"2026-09-19T08:34:01.322Z","contentChangedAt":"2026-09-19T08:34:01.322Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}