Install and Update Codex CLI: Mac, Linux, Windows

가이드에서: Codex CLI Comprehensive Guide

This post has not been translated yet, so you are reading the English original. Read it at the English URL

Installing the OpenAI Codex CLI is one command per platform – curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS and Linux, powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" on Windows – with npm and Homebrew as the supported alternatives, and updating is codex update, which recognizes script, npm, and Homebrew installs and runs that channel’s upgrade.1411 The part most pages skip is what comes after the first command: which of the five install routes to pick, how to pin a version when a release breaks you, why the winget package trails npm by seven minor versions, and what an uninstall leaves behind in ~/.codex. This page is that reference, one table per job, current as of v0.153.4 (September 4, 2026).9

TL;DR

  • The standalone installer is the route OpenAI leads with in both the README and the CLI docs, with npm and Homebrew presented as alternatives (“you can also install” in the CLI docs, “can also be installed via” in the README): the install.sh script on macOS and Linux, the install.ps1 script on Windows. It downloads the compiled binary, so it needs no Node.111
  • npm and Homebrew are supported alternatives. npm install -g @openai/codex pins with a plain package spec (@<version>); brew install --cask codex was at the same 0.153.4 as npm when this was written.1210
  • Avoid winget for installing Codex itself. OpenAI does publish the OpenAI.Codex package, but the manifest pull requests for 0.147.0 through 0.152.0 have sat unmerged in microsoft/winget-pkgs since August 7, 2026, so the newest installable version is 0.146.1 against npm’s 0.153.4 on the day of writing.310
  • codex update covers the script, npm, and Homebrew installs (v0.128.0 and later): it reuses the install-channel detection the TUI already has and runs the matching upgrade. A winget install is not a channel it recognizes; update that one with winget upgrade OpenAI.Codex. The manual equivalents for the rest are re-running the installer, npm install -g @openai/codex@latest, or brew upgrade --cask codex.411
  • Pin with --release <version> on install.sh, $env:CODEX_RELEASE before the install.ps1 line, or @<version> on npm. Homebrew’s cask tracks one current version and cannot pin.212
  • Uninstalling the package does not remove your state, but on a script install rm -rf ~/.codex also deletes the CLI itself, because the installer keeps its releases under ~/.codex/packages/standalone.12

How Do I Install Codex CLI?

Four routes in the order OpenAI’s own docs present them,111 plus winget on Windows, which OpenAI does not document:3

# Standalone installer, no Node required (macOS, Linux, WSL) -- the route OpenAI lists first
curl -fsSL https://chatgpt.com/codex/install.sh | sh

# Windows PowerShell
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"

# npm (needs Node.js 16+; pins with a plain @version spec)
npm install -g @openai/codex

# Homebrew (macOS)
brew install --cask codex

# winget (Windows; lags npm, see the platform section)
winget install OpenAI.Codex

Then confirm it landed and sign in:

codex --version      # codex-cli 0.153.4
codex login          # ChatGPT account (recommended) or an API key

On a first script install the profile block only takes effect in new shells. If codex is not found in the terminal you installed from, run export PATH="$HOME/.local/bin:$PATH" there or open a new one; the installer prints the same two lines (“Current terminal” and “Future terminals”) when it finishes.12

Prefer a raw binary? Every GitHub release ships platform tarballs (codex-aarch64-apple-darwin.tar.gz, codex-x86_64-apple-darwin.tar.gz, codex-x86_64-unknown-linux-musl.tar.gz, codex-aarch64-unknown-linux-musl.tar.gz), and since v0.106.0 the same install.sh is attached to each release as an asset. Each archive holds a single entry with the platform baked into its name, so rename it to codex after extracting.15

The installer fetches from OpenAI-hosted release infrastructure: chatgpt.com/codex/install.sh redirects to releases.openai.com, a change that landed in v0.146.0, with GitHub Releases kept as the fallback host.6 On a network that blocks or throttles OpenAI’s artifact host but allows GitHub, fetch the script from the release asset and tell it to pull the binary from GitHub too:112

curl -fsSL https://github.com/openai/codex/releases/latest/download/install.sh | CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false sh

The variable goes on the sh side of the pipe. A VAR=value curl ... | sh form applies the variable to curl only, so the script never sees it and quietly keeps the default. In PowerShell, set $env:CODEX_INSTALLER_USE_RELEASES_OPENAI_COM = 'false' before running the install line.

Which route should you choose?

You are on Use Why
macOS or Linux the install script The route OpenAI’s docs list first; downloads the binary, no Node on the machine11
Windows the PowerShell script Native PowerShell with the Windows sandbox; WSL is optional811
Any machine where you pin versions in scripts npm install -g @openai/codex@<version> Pins as a package spec, so the version lives in your Dockerfile or provisioning script rather than in a flag10
macOS, where Homebrew already manages everything else brew install --cask codex Same version as npm, no Node dependency, brew upgrade keeps it current2
Windows, package-managed winget install OpenAI.Codex Only if you accept trailing the stable line by weeks3

Which Platforms Does Codex Support?

Platform Status
macOS, Apple silicon and Intel Supported; binaries for both1
Linux, x86_64 and arm64 Supported; binaries for both1
Windows 11 Recommended baseline8
Windows 10, version 1809 or later Best effort (ConPTY console support required)8
Older Windows 10 Not recommended: missing console components8
WSL2 Optional; OpenAI’s WSL page runs the same install script from the WSL shell14

On Windows, Codex runs natively in PowerShell with a Windows sandbox, and there are two sandbox modes. elevated is the preferred one: it uses dedicated lower-privilege sandbox users, filesystem permission boundaries, firewall rules, and local policy changes, and needs an administrator-approved setup. unelevated is the fallback: it runs commands with a restricted Windows token derived from your user and ACL-based filesystem boundaries.8 You select the mode in config.toml:

[windows]
sandbox = "elevated"   # or "unelevated"

OpenAI’s guidance is to use the native sandbox by default and choose WSL when you need Linux-native tooling, when your workflow already lives in WSL2, or when neither native Windows sandbox mode meets your needs.8 One thing to keep straight: the Windows setup assumes winget is present on the machine for its own setup steps; that is separate from installing Codex through winget. OpenAI does publish that package – the release workflow has a winget job that opens a manifest pull request in microsoft/winget-pkgs for stable releases – but those submissions have been sitting unmerged since the 0.146.1 manifest merged on August 7, 2026; the requests for 0.147.0 through 0.152.0 were all still open when this was written, and no request exists for 0.153.0 through 0.153.4 at all. Nothing about the CLI is broken; the package index is behind.38

Node.js is only a requirement for the npm route. The install scripts download the compiled binary, and the Homebrew cask declares no dependencies.12

How Do I Update Codex CLI?

Codex does not update itself. The TUI notices a newer release and offers the command for your install channel; running it is on you, and the built-in one covers the script, npm, and Homebrew installs.4 The startup check itself is a config key: check_for_update_on_startup = false in config.toml, which the reference describes as “Check for Codex updates on startup (set to false only when updates are centrally managed)”; fleets that manage updates centrally set features.in_app_updates = false in requirements.toml.16

codex --version                      # what you run now
npm view @openai/codex version       # newest published

codex update                         # built-in, v0.128.0+; detects your install channel

codex update arrived in v0.128.0 on April 30, 2026; the pull request that added it reused the install-channel detection and update runner the TUI already had for update prompts. The channel map covers npm (plus the bun, pnpm, and Vite+ variants), Homebrew, and the standalone installer on Unix and Windows; a winget install is not in it, so a winget-installed Codex updates through winget upgrade OpenAI.Codex only.4 The manual equivalents, if you prefer them or are scripting a machine image:

curl -fsSL https://chatgpt.com/codex/install.sh | sh   # standalone: re-run the installer
npm install -g @openai/codex@latest                    # npm
brew upgrade --cask codex                              # Homebrew
winget upgrade OpenAI.Codex                            # winget (to whatever winget has)
irm https://chatgpt.com/codex/install.ps1 | iex           # standalone on Windows: re-run the installer

Releases land on a fast stable line – 0.150.0 through 0.153.4 shipped between August 26 and September 4, 2026 – so the gap between “what I run” and “newest” is often a week, not a quarter.9

How Do I Install a Specific Version?

npm and the install script both pin by version; Homebrew does not:212

npm install -g @openai/[email protected]                                          # npm: exact version
curl -fsSL https://chatgpt.com/codex/install.sh | sh -s -- --release 0.152.1  # script: --release flag
curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_RELEASE=0.152.1 sh    # script: env var, on the sh side
winget install OpenAI.Codex --version 0.146.1                                 # winget: only what it has
codex --version                                                               # verify the rollback took

Mind the placement in the env-var form: CODEX_RELEASE=0.152.1 must sit in front of sh, after the pipe. Written in front of curl, the variable applies to curl alone and the script installs latest while you believe you pinned.12 On Windows the PowerShell script declares $Release = $env:CODEX_RELEASE as its only parameter and falls back to latest when it is empty, so the pin is the variable, set in the same session:17

$env:CODEX_RELEASE = '0.152.1'; irm https://chatgpt.com/codex/install.ps1 | iex

Pinning is the right move when a release breaks you: file the issue, pin the last good version, move on. Verify with codex --version after every pin, because a second install elsewhere on your PATH keeps serving its own binary in silence. The install script checks for exactly this: when it finds a Homebrew-, npm-, or bun-managed codex already on your PATH, it warns that “Multiple managed Codex installs can be ambiguous because PATH order decides which one runs” and offers to run the matching uninstall for you.12 codex doctor reports the same condition under Environment after the fact.7

How Do I Uninstall Codex CLI?

Remove it with the route that installed it:

npm uninstall -g @openai/codex
brew uninstall --cask codex
winget uninstall OpenAI.Codex

A script install has no package manager to ask. The installer puts a codex symlink in ~/.local/bin (override with CODEX_INSTALL_DIR) that points at the binary inside ~/.codex/packages/standalone/current (current/bin/codex on current releases); current is itself a symlink into ~/.codex/packages/standalone/releases/, where each downloaded release lives. On macOS the installer adds a second symlink, codex-code-mode-host, beside the first.12 Remove all of it:

rm -f ~/.local/bin/codex ~/.local/bin/codex-code-mode-host   # the second link exists on macOS installs only
rm -rf ~/.codex/packages/standalone

If ~/.local/bin was not on your PATH when you installed, or the installer found a competing Homebrew, npm, or bun install and rewrote the entry, the script also appended a marked block to your shell profile: # >>> Codex installer >>> through # <<< Codex installer <<< in ~/.zprofile (macOS zsh), ~/.bash_profile, ~/.zshrc, ~/.bashrc, or ~/.profile. Delete those three lines to finish.12

On Windows, install.ps1 keeps the same layout under %USERPROFILE%\.codex\packages\standalone (or %CODEX_HOME%\packages\standalone if you set that variable): downloaded releases in releases\, a current junction pointing at the active one. It exposes codex.exe through %LOCALAPPDATA%\Programs\OpenAI\Codex\bin (override with CODEX_INSTALL_DIR), which is itself a junction into current\bin, and instead of a profile block it writes that bin path into your user PATH for future PowerShell sessions. Remove the standalone directory first, then the now-dangling bin junction, then take the entry back out of the user Path variable under Environment Variables:17

Remove-Item -Recurse -Force "$env:USERPROFILE\.codex\packages\standalone"   # releases plus the current junction
cmd /c rmdir "$env:LOCALAPPDATA\Programs\OpenAI\Codex\bin"                  # the bin junction; rmdir removes the link, not a target

The package-manager uninstalls above do not touch ~/.codex/. Homebrew’s --zap does not either, in practice: the cask’s only zap stanza is rmdir: "~/.codex", and Homebrew applies rmdir: only to directories that are already empty.2 That directory holds config.toml, your stored credentials, and every session, which is why a reinstall picks up your login and history where you left them. Delete it only when you want a genuinely clean slate, and know what that means on a script install:

rm -rf ~/.codex   # discards config.toml, credentials, all sessions -- AND the CLI itself on a script install

A clean reinstall that keeps your state is one line on npm: npm uninstall -g @openai/codex && npm install -g @openai/codex@latest. On the script route, re-running the installer replaces the release under ~/.codex/packages/standalone and leaves your config alone.12

The Whole Lifecycle in One Table

Job install.sh (macOS, Linux) install.ps1 (Windows) npm Homebrew winget
Install curl -fsSL https://chatgpt.com/codex/install.sh \| sh powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 \| iex" npm install -g @openai/codex brew install --cask codex winget install OpenAI.Codex
Update codex update, or re-run the script codex update, or re-run the script codex update, or npm install -g @openai/codex@latest codex update, or brew upgrade --cask codex winget upgrade OpenAI.Codex (codex update does not recognize this route)
Pin sh -s -- --release 0.152.1 $env:CODEX_RELEASE = '0.152.1' before the install line npm install -g @openai/[email protected] not supported winget install OpenAI.Codex --version 0.146.1
Uninstall remove the ~/.local/bin symlinks and ~/.codex/packages/standalone remove %USERPROFILE%\.codex\packages\standalone, the %LOCALAPPDATA%\Programs\OpenAI\Codex\bin junction, and the user PATH entry npm uninstall -g @openai/codex brew uninstall --cask codex (--zap does not clear a populated ~/.codex) winget uninstall OpenAI.Codex
Check codex --version, codex doctor same same same same

What Does codex doctor Check?

codex doctor is the command to run before filing a bug or debugging an install that “worked yesterday.” On 0.153.4 it captures seven sections in one report – Notes, Environment (runtime and install consistency), Configuration (config.toml load status, auth, MCP, sandbox policy), Desktop App (added in v0.149.0), Updates, Connectivity, and Background Server – with --summary for a compact view, --json for a redacted machine-readable form, --all to expand truncated lists, and --no-color for logs; codex doctor --help on 0.153.4 also lists --ascii.71315 Most “Codex is broken” reports resolve to something it names on the first screen: a stale auth mode, a config.toml that failed to parse, or a second install shadowing the one on your PATH. The full section-by-section breakdown lives in the guide.

What Changes After Install

The first thing a fresh install trips over is not the binary. Since v0.149.0 the CLI refuses to start on approval_policy = "untrusted", so a config.toml copied from an older machine needs one edit.13 Coming from Claude Code? The migration post maps the two configs side by side, and the hooks post covers what Codex runs around the model. The Codex CLI guide is the full reference: sandbox and approval modes, AGENTS.md, MCP, skills, and cloud tasks. And if you run both tools, the Claude Code install page is this page’s twin.

FAQ

How do I update Codex CLI to the latest version?

Run codex update (v0.128.0 and later); it detects whether you installed through the script, npm, or Homebrew and runs that channel’s upgrade. The manual equivalents are re-running the install script, npm install -g @openai/codex@latest, or brew upgrade --cask codex. A winget install is not a channel codex update recognizes; use winget upgrade OpenAI.Codex for that one.

Does Codex CLI update automatically?

No. The TUI checks for a newer release and offers the update command that matches your install channel, and codex update (v0.128.0 and later) runs it; nothing is downloaded or applied until you do.

How do I uninstall Codex CLI?

Use the route that installed it: npm uninstall -g @openai/codex, brew uninstall --cask codex, or winget uninstall OpenAI.Codex. For a script install, remove the ~/.local/bin/codex symlink (and ~/.local/bin/codex-code-mode-host on macOS) and the ~/.codex/packages/standalone directory. On Windows the script install is %USERPROFILE%\.codex\packages\standalone, the %LOCALAPPDATA%\Programs\OpenAI\Codex\bin junction, and an entry in your user PATH; remove all three. Your config, credentials, and sessions stay in ~/.codex/ until you remove the rest of that directory yourself.

How do I install Codex CLI on Windows?

Run powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex". The CLI runs natively in PowerShell with a Windows sandbox (elevated preferred, unelevated as the fallback); WSL2 is an option when you need Linux tooling or neither sandbox mode fits, not a requirement. Windows 11 is the recommended baseline. winget install OpenAI.Codex also works but trails the stable line.

Do I need Node.js to install Codex?

Only for the npm route, and the package asks for Node 16 or later. The install script, the PowerShell script, and the Homebrew cask all provide the compiled codex binary, so a machine without Node can run Codex.

How do I check which version of Codex I have?

codex --version prints it (for example codex-cli 0.153.4). npm view @openai/codex version shows the newest published version, and codex doctor reports the install path and whether another copy on your PATH is shadowing it.



  1. OpenAI, openai/codex README – the install section leads with curl -fsSL https://chatgpt.com/codex/install.sh | sh for macOS and Linux and the PowerShell install.ps1 one-liner for Windows, then says the CLI “can also be installed via” npm (npm install -g @openai/codex) and Homebrew (brew install --cask codex); documents curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false sh and the $env:CODEX_INSTALLER_USE_RELEASES_OPENAI_COM='false' PowerShell form, introduced with “To force GitHub Releases, set CODEX_INSTALLER_USE_RELEASES_OPENAI_COM to false (0 and no are also accepted)”; the @openai/codex package name; platform binaries for macOS (Apple silicon, x86_64) and Linux (x86_64, arm64) on GitHub Releases. Verified 2026-09-06. 

  2. Homebrew, cask codex – cask token codex, a single current version (0.153.4 on 2026-09-06), a bin/codex binary artifact, and an empty depends_on. Verified via the formulae API 2026-09-06. The cask’s zap stanza is zap rmdir: "~/.codex", and the Cask Cookbook defines rmdir: as paths of directories to remove if empty. 

  3. Microsoft, winget-pkgs manifests for OpenAI.Codex – 119 published versions, newest 0.146.1, on 2026-09-06. The package is published by OpenAI: .github/workflows/rust-release.yml in openai/codex has a winget job that runs the winget-releaser action for stable releases. The resulting pull requests by oai-fork-bot for 0.147.0 (#413497, opened August 7) through 0.152.0 (#427090, opened September 1) were open and unmerged on 2026-09-06; the last merged was 0.146.1 (#412766, merged August 7), and a search of the repository finds no pull request for any 0.153.x release. OpenAI’s README and CLI docs do not mention winget. 

  4. OpenAI, Codex CLI v0.128.0 release notes, April 30, 2026 – “Added codex update, configurable TUI keymaps, plan-mode nudges, action-required terminal titles, and active-turn /statusline and /title edits.” The command’s pull request, openai/codex #19933 (merged April 28, 2026), states it “Reused the existing install-channel detection and update command runner that the TUI already uses for update prompts.” The channel map is codex-rs/tui/src/update_action.rs: npm and its bun, pnpm, and Vite+ siblings, Homebrew, and the standalone installer (Unix and Windows); no winget variant (read 2026-09-06). 

  5. OpenAI, Codex CLI v0.106.0 release notes, February 26, 2026 – “Added a direct install script for macOS and Linux and publish it as a GitHub release asset, using the existing platform payload (including codex and rg)”; install.sh is attached to every release since. 

  6. OpenAI, Codex CLI v0.146.0 release notes, July 29, 2026 – “Publish release artifacts, channel metadata, and installer aliases through OpenAI-hosted release infrastructure, with GitHub fallback.” https://chatgpt.com/codex/install.sh answers 302 to https://releases.openai.com/codex/install.sh (checked 2026-09-06). 

  7. OpenAI, feat(cli): add codex doctor diagnostics, openai/codex PR #22336, merged May 13, 2026 – the report’s sections (Notes, Environment, Configuration, Updates, Connectivity, Background Server) and its --summary, --json, --all, and --no-color flags. 

  8. OpenAI, Codex on Windows: Windows sandbox – the elevated (preferred) and unelevated (fallback, restricted Windows token) sandbox modes and the [windows] sandbox setting; WSL for Linux-native tooling, an existing WSL2 workflow, or when neither native mode fits; Windows 11 recommended, Windows 10 1809+ best effort, older Windows 10 not recommended; winget expected to be available for setup. Verified 2026-09-06. 

  9. OpenAI, openai/codex releasesrust-v0.153.4 published September 4, 2026 as the latest release; rust-v0.150.0 on August 26, 2026. Dates from the GitHub releases API, 2026-09-06. 

  10. npm, @openai/codexlatest = 0.153.4 and engines: { node: ">=16" } on 2026-09-06 (npm view @openai/codex version engines). 

  11. OpenAI, Codex CLI documentation – installation leads with the standalone installer (curl -fsSL https://chatgpt.com/codex/install.sh | sh on macOS and Linux, a Windows installer tab), presents Homebrew and npm as alternatives, and gives re-running the installer as the update for standalone installs. Verified 2026-09-06. 

  12. OpenAI, the install.sh installer script as served 2026-09-06 – Usage: install.sh [--release VERSION]; environment variables CODEX_RELEASE (“Version to install; overridden by –release”), CODEX_INSTALL_DIR (default ~/.local/bin), CODEX_HOME (default ~/.codex), and CODEX_INSTALLER_USE_RELEASES_OPENAI_COM (“Set to 0, false, or no to use GitHub Releases”); releases stored under ~/.codex/packages/standalone/releases behind a current symlink, with a codex symlink (and codex-code-mode-host on macOS) in the bin directory; a # >>> Codex installer >>> / # <<< Codex installer <<< PATH block appended to ~/.zprofile, ~/.bash_profile, ~/.zshrc, ~/.bashrc, or ~/.profile when the bin directory is not already on PATH or a competing managed install was detected (add_to_path returns early on a PATH match only when no conflict was found); and the conflicting-install check that warns “Multiple managed Codex installs can be ambiguous because PATH order decides which one runs” and offers brew uninstall --cask codex, npm uninstall -g @openai/codex, or bun remove -g @openai/codex

  13. OpenAI, Codex CLI v0.149.0 release notes, August 20, 2026 – includes #39630, “Retire the untrusted approval policy,” and “codex doctor now diagnoses endpoint protection, network/proxy failures, desktop app state, and update connectivity.” 

  14. OpenAI, Codex on Windows: WSL – “Use Codex CLI with WSL”: wsl --install, open a WSL shell, then curl -fsSL https://chatgpt.com/codex/install.sh | sh and codex; the page also advises keeping repositories under the Linux home directory rather than Windows-mounted /mnt/c/ paths, for faster I/O. 

  15. Author’s reproduction on Codex CLI 0.153.4 (npm install), 2026-09-06: codex doctor --summary --no-color prints the sections Notes, Environment, Configuration, Desktop App, Updates, Connectivity, and Background Server, in that order; codex doctor --help lists --ascii

  16. OpenAI, Codex config referencecheck_for_update_on_startup (boolean): “Check for Codex updates on startup (set to false only when updates are centrally managed)”; features.in_app_updates (boolean): “Set to false in requirements.toml to disable in-app updates. Updates remain enabled by default when this requirement is omitted.” Verified 2026-09-06. 

  17. OpenAI, the install.ps1 installer script as served 2026-09-06 – parameter block param([string]$Release = $env:CODEX_RELEASE) with latest as the fallback; $codexHome = CODEX_HOME or %USERPROFILE%\.codex; packages\standalone with releases\, a current junction and install.lock; the visible bin directory %LOCALAPPDATA%\Programs\OpenAI\Codex\bin (or CODEX_INSTALL_DIR) created as a junction to current\bin; the user-scope Path written with [Environment]::SetEnvironmentVariable("Path", ..., "User") (“PATH updated for future PowerShell sessions.”). 

관련 게시물

Install and Update Claude Code CLI: Mac, Linux, Windows

Every way to install, update, pin, and uninstall the Claude Code CLI -- native installer, Homebrew, winget, or npm -- on…

7 분 소요

Codex untrusted Approval Policy Retired: What to Change

Codex CLI 0.149 retired the untrusted approval policy and now refuses to start on it. The error, who must edit, and the …

15 분 소요

Foundation Models from Python: the fm CLI

macOS 27 ships the fm command line tool plus a Foundation Models SDK for Python, so you can script Apple's on-device mod…

14 분 소요