diff --git a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__standalone_unix_update_available_history_cell_snapshot.snap b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__standalone_unix_update_available_history_cell_snapshot.snap index c8f352dbb4..8f1548cf88 100644 --- a/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__standalone_unix_update_available_history_cell_snapshot.snap +++ b/codex-rs/tui/src/history_cell/snapshots/codex_tui__history_cell__tests__standalone_unix_update_available_history_cell_snapshot.snap @@ -2,10 +2,11 @@ source: tui/src/history_cell/tests.rs expression: rendered --- -╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ -│ ✨ Update available! 0.0.0 -> 9.9.9 │ -│ Run sh -c 'curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh' to update. │ -│ │ -│ See full release notes: │ -│ https://github.com/openai/codex/releases/latest │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ ✨ Update available! 0.0.0 -> 9.9.9 │ +│ Run sh -c 's=$(curl -fsSL https://chatgpt.com/codex/install.sh) && CODEX_NON_INTERACTIVE=1 eval "$s"' to │ +│ update. │ +│ │ +│ See full release notes: │ +│ https://github.com/openai/codex/releases/latest │ +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/codex-rs/tui/src/update_action.rs b/codex-rs/tui/src/update_action.rs index 860d0bd102..7b3433e992 100644 --- a/codex-rs/tui/src/update_action.rs +++ b/codex-rs/tui/src/update_action.rs @@ -20,7 +20,7 @@ pub enum UpdateAction { PnpmGlobalLatest, /// Update via `brew upgrade codex`. BrewUpgrade, - /// Update via `curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh`. + /// Update via the standalone Unix installer. StandaloneUnix, /// Update via `$env:CODEX_NON_INTERACTIVE=1; irm https://chatgpt.com/codex/install.ps1 | iex`. StandaloneWindows, @@ -56,7 +56,7 @@ impl UpdateAction { "sh", &[ "-c", - "curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh", + r#"s=$(curl -fsSL https://chatgpt.com/codex/install.sh) && CODEX_NON_INTERACTIVE=1 eval "$s""#, ], ), UpdateAction::StandaloneWindows => ( @@ -156,17 +156,7 @@ mod tests { } #[test] - fn standalone_update_commands_rerun_latest_installer() { - assert_eq!( - UpdateAction::StandaloneUnix.command_args(), - ( - "sh", - &[ - "-c", - "curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh" - ][..], - ) - ); + fn standalone_windows_update_command_reruns_latest_installer() { assert_eq!( UpdateAction::StandaloneWindows.command_args(), ( @@ -180,6 +170,23 @@ mod tests { ) ); } + + #[cfg(unix)] + #[test] + fn standalone_unix_update_fails_when_installer_download_fails() { + let (command, args) = UpdateAction::StandaloneUnix.command_args(); + let offline_command = args[1].replace("https://chatgpt.com", "file:///dev/null"); + assert_ne!(offline_command, args[1], "installer URL must be replaced"); + let output = std::process::Command::new(command) + .args([args[0], &offline_command]) + .env_clear() + .env("HOME", "/dev/null") + .env("PATH", "/usr/bin:/bin") + .output() + .expect("run standalone Unix update command"); + + assert!(!output.status.success(), "{output:?}"); + } } /// Package source explicitly selected by the user in the daemon menu.