Installing Codex looks trivial, but behind it are several decisions that later affect updates and reproducibility. There are three main ways: the standalone installer via the official script, the global npm package and the Homebrew cask on macOS. On Windows the standalone is installed via PowerShell. The installation method is worth choosing consciously from the start, because it determines how the binary will update later and where to look for the cause if the version does not change.
The key difference between the methods is the update model, and it is tied to the installation method. There is a codex update command that updates Codex to the latest version, but its applicability depends on how the binary was installed. The standalone is updated by rerunning the installer or via codex update; npm by a repeated global install (npm install -g @openai/codex); Homebrew by brew upgrade --cask codex. Package installs are usually updated by their own manager rather than codex update - and this is a frequent source of confusion.
Right after installation you do a minimal check rather than rushing into a task. command -v codex answers where the binary is launched from; codex --version records the specific version; codex --help shows the current set of commands and flags. These three lines are worth running before the first work: reproducibility begins with knowing which version you run, not with assuming it.
It helps to see the install commands for all platforms side by side once. Below are the standalone, npm and Homebrew for macOS and Linux, and the standalone for Windows. You return to this map when setting up a new environment: it shows exactly where the decision about the installation method is made, on which all the update logic then depends. For CI you consciously choose either an explicit version or a pre-built image rather than relying on "just install the latest".
If the version has not changed after an update, the first step is not a reinstall but checking the cause. Most often it is the PATH or several parallel Codex installations: you updated one, but another is launched. command -v codex and codex --version quickly show which binary is actually in play. A blind reinstall on top of this only muddies the picture, whereas one PATH check usually names the culprit at once.
Uninstalling is deliberately separated, and it matters to understand this in advance. Removing the binary is one action, and clearing user state is quite another. The CODEX_HOME directory (by default ~/.codex) contains config, auth, sessions, skills, logs and package metadata. Wiping it as the first step of diagnostics means losing authorization, session history and settings at once. First you remove the binary, and the configuration you touch separately and consciously, with a backup if it might be needed.
The installers have variables for automation worth knowing. The standalone understands CODEX_NON_INTERACTIVE - it disables interactive prompts during installation - and CODEX_INSTALL_DIR, which changes the location of the visible command. An important subtlety: the package cache is still tied to CODEX_HOME, so CODEX_INSTALL_DIR changes only the location of the executable, not all the state. In CI such variables let you install Codex deterministically, without manual confirmation.
The typical installation failures are predictable. Expecting codex update to update an install owned by a package manager. Reinstalling blindly without checking the PATH and parallel installations. Wiping ~/.codex as the first step and losing auth and sessions. And relying on "the latest version" in CI instead of an explicit pin, getting different run behavior. Install consciously, check the version with a command, and guard the user state separately from the binary.
# macOS and Linux
curl -fsSL https://chatgpt.com/codex/install.sh | sh # standalone
npm install -g @openai/codex # npm
brew install --cask codex # Homebrew
# Windows (standalone)
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"# Checks after installation
command -v codex # where it launches from
codex --version # which version
codex --help # current commands and flags
# CI: no interaction
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_NON_INTERACTIVE=1 sh
# CODEX_HOME (default ~/.codex) holds config, auth, sessions, skills, logs