Skip to content

Commit 024163c

Browse files
Gabriele Karragabrielekarra
authored andcommitted
Fix brew update issue by running brew update before upgrade
1 parent 917f39e commit 024163c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

codex-rs/cli/src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ fn handle_app_exit(exit_info: AppExitInfo) -> anyhow::Result<()> {
269269
/// Run the update action and print the result.
270270
fn run_update_action(action: UpdateAction) -> anyhow::Result<()> {
271271
println!();
272+
273+
// For Homebrew installations, run `brew update` first to sync the cask index.
274+
// Without this, `brew upgrade` may incorrectly report "already latest" when
275+
// a newer version exists but the local cask index is stale.
276+
if action == UpdateAction::BrewUpgrade {
277+
println!("Syncing Homebrew cask index...");
278+
let update_status = std::process::Command::new("brew").arg("update").status()?;
279+
if !update_status.success() {
280+
anyhow::bail!("`brew update` failed with status {update_status}");
281+
}
282+
}
283+
272284
let (cmd, args) = action.command_args();
273285
let cmd_str = action.command_str();
274286
println!("Updating Codex via `{cmd_str}`...");

0 commit comments

Comments
 (0)