can1357/oh-my-pi · error · Error
brew ${args[0]} failed with exit code ${result.exitCode}
Error message
brew ${args[0]} failed with exit code ${result.exitCode} What it means
Thrown when the actual Homebrew upgrade (`brew upgrade` or `brew install <formula>`, per buildHomebrewUpdateArgs) exits non-zero after a successful `brew update`. The formula index is current, but installing/upgrading the formula itself failed.
Source
Thrown at packages/coding-agent/src/cli/update-cli.ts:1666
console.log(
chalk.yellow(
`This install is no longer managed by ${steps.manager}. Removing the old global package may delete this launcher; if it does, reinstall with: ${installerHint()}`,
),
);
}
async function updateViaHomebrew(expectedVersion: string, force: boolean): Promise<void> {
console.log(chalk.dim("Updating Homebrew formulae..."));
const update = await $`brew update`.nothrow();
if (update.exitCode !== 0) {
throw new Error(`brew update failed with exit code ${update.exitCode}`);
}
console.log(chalk.dim("Updating via Homebrew..."));
const args = buildHomebrewUpdateArgs(force);
const result = await $`brew ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`brew ${args[0]} failed with exit code ${result.exitCode}`);
}
await printVerification(expectedVersion);
}
async function updateViaMise(expectedVersion: string, force: boolean): Promise<void> {
console.log(chalk.dim("Updating via mise..."));
const args = buildMiseUpgradeArgs();
const result = await $`mise ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`mise upgrade failed with exit code ${result.exitCode}`);
}
if (force) {
const forceArgs = buildMiseForceInstallArgs(expectedVersion);
const forceResult = await $`mise ${forceArgs}`.nothrow();
if (forceResult.exitCode !== 0) {
throw new Error(`mise install --force failed with exit code ${forceResult.exitCode}`);View on GitHub (pinned to 9690622007)
Solutions
- Run the same `brew upgrade <formula>` manually to see brew's error output
- Ensure `brew update` succeeded and the formula has the expected version (`brew info <formula>`)
- Check for stale brew locks (`rm -f $(brew --prefix)/var/homebrew/locks/*.lock`) or concurrent brew processes
- Free disk space / install Xcode CLT if the error indicates build issues
- Fall back to the standalone binary installer or another package manager
Example fix
// before
const result = await $`brew ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`brew ${args[0]} failed with exit code ${result.exitCode}`);
}
// after
const result = await $`brew ${args}`.nothrow();
if (result.exitCode !== 0) {
throw new Error(`brew ${args.join(" ")} failed (${result.exitCode}): ${result.stderr.text()}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
const info = await $`brew info ${formula}`.nothrow();
if (info.exitCode !== 0 || !info.text().includes(expectedVersion)) {
console.warn("formula version not yet available via brew");
} Type guard
function brewUpgradeOk(r: { exitCode: number }): r is { exitCode: 0 } {
return r.exitCode === 0;
} Try / catch
try {
await updateSelf({ method: "homebrew" });
} catch (err) {
if (/brew \S+ failed/.test(err.message)) {
// run `brew upgrade <formula>` manually to see brew's real diagnostics
} else throw err;
} Prevention
- Don't run concurrent brew processes (lock contention)
- Keep Xcode CLT installed for source builds
- Check `brew info <formula>` for version availability before scripted upgrades
When it happens
Trigger: `brew upgrade <pkg>` / `brew install <pkg>` fails: build-from-source failure, unresolved dependencies, another brew process holding the lock, or the formula version not yet in the API.
Common situations: Formula lags behind the released version; concurrent brew runs (lock contention); Xcode CLT missing for source builds; disk space exhausted.
Related errors
- brew update failed with exit code ${update.exitCode}
- mise upgrade failed with exit code ${result.exitCode}
- bun install failed with exit code ${result.exitCode}
- npm install failed with exit code ${result.exitCode}
- mise install --force failed with exit code ${forceResult.exi
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/7a92c79c7cc269f7.
Report an issue: GitHub.