All tutorials / Codex/6 min/Beginner

Codex tutorial

How to update OpenAI Codex CLI

Update Codex safely, refresh your shell path, verify auth, and run a tiny smoke test before using it in real projects.

4 stepsCopyable commandsCodex CLI
Interactive tutorial

Quick command sequence

$ which codex && codex --version && brew upgrade openai-codex || npm update -g @openai/codex && codex exec --skip-git-repo-check "Say updated"

/en/tutorials/how-to-update-openai-codex-cli

Interactive command lab

1/4

Step 1

Check the installed Codex CLI

Start by checking the binary path and version so you know whether Homebrew, npm, or another installer owns the command.

Checkpoint

If multiple codex binaries exist, update the one your shell actually uses.

zsh — tutorial-lab

Command tray

$ which codex && codex --version

/opt/homebrew/bin/codex

codex-cli 0.42.0

Step-by-step instructions

  1. 1

    Step

    Check the installed Codex CLI

    Start by checking the binary path and version so you know whether Homebrew, npm, or another installer owns the command.

    which codex && codex --version
  2. 2

    Step

    Update with the matching package manager

    Prefer the same package manager that installed Codex. Mixing installers can leave stale binaries earlier in PATH.

    brew upgrade openai-codex || npm update -g @openai/codex
  3. 3

    Step

    Refresh your shell path

    Some shells cache command locations. Reload before checking the version again.

    hash -r 2>/dev/null || true
    exec $SHELL -l
  4. 4

    Step

    Verify auth and model access

    A version number is not enough. Run a tiny exec to verify auth, model routing, and the updated CLI all work.

    codex exec --skip-git-repo-check "Say updated"

Why this matters

CLI updates can fail quietly when multiple package managers install the same command. This flow proves you updated the executable your terminal actually uses.

Troubleshooting

  • If the version does not change, run type -a codex and remove stale binaries.
  • If auth fails after updating, run Codex login again.
  • If npm global update fails, fix npm permissions instead of using sudo blindly.

Related tutorials