Skip to content

Commit e4068eb

Browse files
committed
Fix brew update issue by running brew update before upgrade
When Codex is installed via Homebrew, the internal updater now runs 'brew update' before 'brew upgrade --cask codex' to ensure the cask index is synced. Without this, brew may incorrectly report 'already latest' when a newer version exists but the local cask index is stale. Fixes openai#6253 Signed-off-by: Salvatore KARRA <[email protected]> Signed-off-by: Salvatore KARRA <[email protected]>
1 parent 9b538a8 commit e4068eb

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
@@ -267,6 +267,18 @@ fn handle_app_exit(exit_info: AppExitInfo) -> anyhow::Result<()> {
267267
/// Run the update action and print the result.
268268
fn run_update_action(action: UpdateAction) -> anyhow::Result<()> {
269269
println!();
270+
271+
// For Homebrew installations, run `brew update` first to sync the cask index.
272+
// Without this, `brew upgrade` may incorrectly report "already latest" when
273+
// a newer version exists but the local cask index is stale.
274+
if action == UpdateAction::BrewUpgrade {
275+
println!("Syncing Homebrew cask index...");
276+
let update_status = std::process::Command::new("brew").arg("update").status()?;
277+
if !update_status.success() {
278+
anyhow::bail!("`brew update` failed with status {update_status}");
279+
}
280+
}
281+
270282
let (cmd, args) = action.command_args();
271283
let cmd_str = action.command_str();
272284
println!("Updating Codex via `{cmd_str}`...");

0 commit comments

Comments
 (0)