Skip to content

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

Codex CLI Complete Guide

What you will solve in this guide

Run the current Codex CLI self-update command first Fix the common case where an old binary still appears after update Standardize the install channel so future updates do not drift

For the search intent "update codex cli", the answer is now direct: run codex update first. Current Codex CLI reference lists codex update as the stable command that checks for and applies a CLI update when the installed release supports self-update.

If codex update is unavailable, cannot detect the installation method, or codex --version still looks old, the problem usually moves from "how do I update?" to "which codex binary is my shell launching?" That is where PATH duplicates, shell command caches, and mixed install channels still matter.

Current answer for update codex cli

codex update
codex --version

If the updater says it cannot detect the installation method, update from the same channel you originally used, then verify the binary path.

Target Audience

  • Developers who want the current Codex CLI update command
  • Developers whose terminal still launches an old Codex binary after updating
  • Tech leads standardizing Codex CLI installs across a team

Key Points

  1. Start with codex update, not a clean reinstall.
  2. If the version still looks old, locate every codex executable in PATH.
  3. Keep one install channel per machine: standalone installer, npm, Homebrew, or another managed channel.

Why Codex CLI updates fail to apply

Most failed update reports fall into four buckets.

The common root causes

codex update only works when the installed release supports self-update and can identify how Codex was installed. If it cannot, rerun the installer or package manager that created your current codex command.

Installing Codex through multiple channels can leave several codex executables behind. The oldest one often appears first in PATH, especially on Windows where %AppData%\npm, %LOCALAPPDATA%\Programs\OpenAI\Codex\bin, and ad-hoc copies can coexist.

Bash and Zsh cache command locations. Unless you open a new terminal or run hash -r / rehash after upgrading, the shell can keep using a stale path.

GitHub Issue #4986 reported a case where codex --version returned the wrong release. That issue is closed, so treat it as a historical diagnostic clue, not the first assumption.

Windows is not only WSL

Current Codex docs say the CLI is available on macOS, Windows, and Linux. On Windows, Codex can run natively in PowerShell with the Windows sandbox, or inside WSL2 when you need a Linux-native environment. Use WSL2 when your workflow already lives there or native Windows sandboxing does not meet your needs.

3-minute diagnostic for update codex cli

Run the current updater first.

codex update
codex --version

If that works, stop. If it fails or the old version still appears, inspect the binary path.

# macOS / Linux / WSL
which -a codex
command -v codex
# Windows PowerShell
Get-Command codex -All | Select-Object -Expand Source
where.exe codex

Seeing multiple paths means the update probably succeeded somewhere, but the terminal is launching a different executable.

Use a fresh shell before deleting anything

Open a brand-new terminal after every update attempt. If you stay in the same Bash or Zsh session, run hash -r or rehash before checking again.

Three steps to guarantee an update

Use this order. It avoids unnecessary reinstall work when codex update already handles the job.

Step 1: Try the official self-update path

codex update
codex --version
codex doctor --summary

If codex doctor --summary is unavailable in your installed version, skip it and continue. Older releases may not have every current diagnostic command.

Step 2: Repair the original install channel

If codex update cannot determine how Codex was installed, use the same channel that created the codex command.

# Standalone installer on macOS / Linux / WSL
curl -fsSL https://chatgpt.com/codex/install.sh | sh
# Standalone installer on Windows PowerShell
irm https://chatgpt.com/codex/install.ps1 | iex

If you intentionally installed with npm or Homebrew, update through that same channel instead of mixing channels.

# npm-managed install
npm install -g @openai/codex@latest

# Homebrew-managed install
brew upgrade codex || brew install codex

Step 3: Remove duplicates only after path proof

Do not uninstall everything by habit. First prove there is more than one executable.

# macOS / Linux / WSL
which -a codex
hash -r
codex --version
# Windows PowerShell
Get-Command codex -All | Select-Object -Expand Source
codex --version

If multiple paths remain, remove the channel you no longer want to use.

# npm-managed install
npm uninstall -g @openai/codex

# Homebrew-managed install
brew uninstall codex

For standalone installs, remove only the old standalone binary path you confirmed is no longer the desired one. On Windows, check %LOCALAPPDATA%\Programs\OpenAI\Codex\bin before deleting ad-hoc copies elsewhere.

What success looks like

You should see one intended codex path, and codex --version should report the updated CLI after a fresh terminal launch.

Common failure patterns and fixes

SymptomLikely causeFix
codex update says it cannot detect the install methodUpdater cannot map the current install channelRerun the standalone installer or the same package manager you originally used
codex update command is missingOlder CLI releaseUpdate through the original install channel, then use codex update for future updates
codex --version is old after a successful updatePATH precedence or shell cacheRun which -a codex / Get-Command codex -All, open a fresh terminal, then remove stale copies
npx -y @openai/codex@latest --version is newer than codex --versionnpm package is current, but PATH points elsewhereFix PATH order or remove the stale global binary
Native Windows workflow is unstableWindows sandbox or local policy issueUse the native Windows sandbox by default, then switch to WSL2 if your workflow or policy needs Linux-native behavior
VS Code or Cursor extension feels outdatedExtension version lagUpdate the extension manually and restart the editor
How to update the VS Code extension
  1. Open the Extensions sidebar in VS Code
  2. Search for "OpenAI Codex"
  3. Click Update
  4. Fully restart VS Code
  5. Sign back into Codex from the sidebar

Key takeaways

For update codex cli, the current first command is:

codex update

If that does not resolve the issue, do not guess. Locate the binary, confirm the install channel, open a fresh shell, and remove only the stale path you can prove is being launched.

Future upgrades stay predictable when each machine uses one Codex install channel and treats codex update as the normal update path.

What to do next

Further reading