Skip to content

Update Codex CLI: Use codex update, Then Fix PATH Duplicates

Codex CLI Complete Guide

For / Key Points

For: Developers whose terminal still launches an older Codex CLI after an update

Key Points:

  • Run codex update first
  • If the version does not change, locate every executable in PATH
  • Standardize on one installation channel per machine

The current first step is codex update. On supported installed releases, it checks for and applies a Codex CLI update.1

codex update
codex --version

If codex update is unavailable, cannot detect the installation method, or leaves the reported version unchanged, find out which codex executable the shell is launching before reinstalling again.

Three reasons an update appears not to apply

Self-update may not complete when the installed release does not support it or Codex cannot identify the installation method. Update through the installer or package manager that originally created the command.

Mixing npm, Homebrew, a standalone build, and manually copied files can leave multiple codex commands in PATH. The shell may select an older binary before the one that was updated.

Bash and Zsh can cache command locations. If you keep the same terminal open after updating, you may need hash -r or rehash.

Diagnose it in three minutes

1. Try self-update

codex update
codex --version
codex doctor --summary

If an older CLI does not have codex doctor --summary, skip that line. Open a new terminal after the update and check codex --version again.

2. Identify the executable being launched

On macOS, Linux, and WSL:

which -a codex
command -v codex

On Windows PowerShell:

Get-Command codex -All | Select-Object -ExpandProperty Source
where.exe codex

When several paths appear, the first one is the likely executable being launched. Identify how each copy was installed before removing anything.

3. Update through the original channel

For a standalone installation, rerun the installer shown in the official repository.2

curl -fsSL https://chatgpt.com/codex/install.sh | sh
irm https://chatgpt.com/codex/install.ps1 | iex

If npm or Homebrew manages the installation, update through that same channel instead of adding another one.

npm install -g @openai/codex@latest

brew upgrade --cask codex || brew install --cask codex

Remove duplicates safely

Remove an unused installation channel only after confirming the duplicate.

npm uninstall -g @openai/codex

brew uninstall --cask codex

For standalone or manually copied binaries, target only the old path confirmed by which -a or Get-Command. Do not guess its location.

If you continue using the same Bash or Zsh session, clear its command cache before checking again.

hash -r
codex --version

Use rehash instead of hash -r in Zsh environments configured around that command.

Definition of done

The intended codex path appears first, and codex --version reports the updated CLI in a new terminal.

Match the symptom to the check

SymptomWhat to inspectAction
codex update is missingInstalled CLI ageUpdate through the original installation channel
The updater cannot detect the install methodCurrent management channelUse the same installer or package manager
The version stays old after an updatePATH precedenceRun which -a or Get-Command -All
A new terminal fixes itShell command cacheClose the old session or run hash -r

Windows does not require WSL

Codex CLI is available on macOS, Windows, and Linux. The official Windows guide covers both native PowerShell use and WSL2. Choose based on your working environment and sandbox requirements.3

Summary

Start with codex update. If it does not apply, use which -a codex or Get-Command codex -All to identify the executable, then update through its original installation channel.

Remove duplicates only after proving which paths exist. Keeping one installation channel per machine makes later updates easier to diagnose.