{"record":{"id":"3a4b5317548de547","repo":"lbjlaq/Antigravity-Manager","slug":"brew-exec-failed","errorCode":"brew_exec_failed","errorMessage":"brew_exec_failed","messagePattern":"brew_exec_failed","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/modules/update_checker.rs","lineNumber":522,"sourceCode":"        \"/usr/local/bin/brew\"\n    } else {\n        return Err(\"brew_not_found\".to_string());\n    };\n\n    // 3 min timeout to prevent hanging\n    let result = tokio::time::timeout(\n        std::time::Duration::from_secs(180),\n        tokio::process::Command::new(brew_path)\n            .args([\"upgrade\", \"--cask\", \"antigravity-tools\"])\n            .output(),\n    )\n    .await;\n\n    let output = match result {\n        Ok(Ok(output)) => output,\n        Ok(Err(e)) => {\n            logger::log_error(&format!(\"Failed to execute brew upgrade: {}\", e));\n            return Err(\"brew_exec_failed\".to_string());\n        }\n        Err(_) => {\n            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        ));","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/lbjlaq/Antigravity-Manager/blob/90a2b6b20797e2e593a83d0c54ab86037863fe70/src-tauri/src/modules/update_checker.rs#L504-L540","documentation":"brew_upgrade_cask (src-tauri/src/modules/update_checker.rs) runs `/opt/homebrew/bin/brew` (or /usr/local/bin/brew) via tokio::process::Command to `brew upgrade --cask antigravity-tools`. 'brew_exec_failed' is returned when the process itself could not be spawned or failed before producing output (the Ok(Err(e)) arm of the output match) — e.g. the brew binary is not executable, is corrupted, or the spawn call errored. It is distinct from brew_timeout (3-minute limit hit) and from brew exit-code failures.","triggerScenarios":"tokio::process::Command::output() returns Err while running brew upgrade — brew binary exists at the checked path but cannot be executed (bad permissions, broken symlink, architecture mismatch), the fork/exec failed, or resource limits prevented spawning the child process.","commonSituations":"Homebrew partially uninstalled or migrated (leftover non-executable /opt/homebrew/bin/brew); Intel vs Apple Silicon path pointing at a stale binary; macOS quarantine/xattr flags on brew; PATH/env corruption inside the GUI app context; disk-full or sandbox preventing process spawn.","solutions":["Verify the brew binary is executable and works: run `/opt/homebrew/bin/brew --version` (or /usr/local/bin/brew) in Terminal; reinstall Homebrew if it errors.","Reinstall/repair Homebrew (`/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"`) if the binary is corrupted or the install was partially removed.","Check the binary matches your CPU architecture (arm64 brew under /opt/homebrew, x86_64 under /usr/local); remove the wrong-architecture install.","Clear quarantine attributes if present: `xattr -d com.apple.quarantine /opt/homebrew/bin/brew`.","Retry the in-app upgrade after confirming brew works from the command line; the error is a one-shot spawn failure, not a stateful condition."],"exampleFix":"// before: app reports brew_exec_failed because /opt/homebrew/bin/brew lost +x\n// terminal check & fix:\nls -l /opt/homebrew/bin/brew          // -rw-r--r-- (not executable)\nchmod +x /opt/homebrew/bin/brew\nbrew --version                        // after: works, in-app upgrade succeeds","handlingStrategy":"try-catch","validationCode":"// Pre-check brew executability before invoking the upgrade command\nimport { existsSync, accessSync, constants } from 'fs';\nconst brew = ['/opt/homebrew/bin/brew', '/usr/local/bin/brew'].find(p => {\n  try { accessSync(p, constants.X_OK); return true; } catch { return false; }\n});\nif (!brew) throw new Error('brew binary missing or not executable');","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('brew_upgrade_cask');\n} catch (e) {\n  if (e === 'brew_exec_failed') {\n    // guide user to repair Homebrew / check brew binary in Terminal\n    showRepairHomebrewDialog();\n  } else throw e;\n}","preventionTips":["Periodically verify `brew --version` works in Terminal on macOS build/test machines.","Keep Homebrew installs architecture-correct (arm64 -> /opt/homebrew, x86_64 -> /usr/local).","Avoid partial Homebrew removals; use the official uninstall script when migrating.","Watch for quarantine attributes on the brew binary after manual copies; clear with xattr.","Surface the log line 'Failed to execute brew upgrade: <io error>' to diagnose the spawn failure."],"tags":["homebrew","macos","process-spawn","update"],"backgroundTag":"command-execution-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"}