codex: command not found after installing
The shell cannot resolve the command name, which means either nothing was installed in a place this shell searches, or the install succeeded but its directory is not on PATH. The two cases need different fixes.
Start here
Check which shell you are in, then open a brand-new terminal.
What you see
The install step looked fine, but the shell answers:
codex: command not found
or, on Windows:
'codex' is not recognized as an internal or external command,
operable program or batch file.
The shell is saying it searched the directories listed in PATH and did not find an executable named codex. It says nothing at all about whether Codex is installed.
What it usually means
There are three distinct situations, and they need different fixes:
- Nothing was installed. An installer can exit “successfully” while a download step failed, or you may have installed a different package.
- It is installed, but not where this shell looks. This is the most common case. The binary exists; its directory is not on
PATHfor the shell you are using. A GUI terminal and a shell started from an IDE often inherit different environments. - You are in a different environment than the one you installed into. This is the classic WSL case: you installed inside Windows and are running a Linux shell, or the reverse. The two do not share installed programs.
Quick checks
- Which shell and which system am I actually in? In WSL this matters more than anything else. If you installed with the Windows PowerShell installer, the command belongs in Windows terminals, not in a WSL shell.
- Does it work in a brand-new terminal? Open a fresh one. A PATH change made by an installer only reaches terminals started afterwards.
- Does it work when called by absolute path? If you can run the binary from the directory it was installed to, the install is fine and this is purely a PATH problem.
- Which install method did you actually use? Re-read the command you ran. The documented methods install to different places:
- macOS / Linux standalone:
curl -fsSL https://chatgpt.com/codex/install.sh | sh - Windows standalone:
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex" - npm:
npm install -g @openai/codex - Homebrew:
brew install --cask codex
- macOS / Linux standalone:
Fixes, by branch
If a fresh terminal still cannot find it
- Confirm the install command you used is one of the documented methods above, exactly as written. A typo in the URL or package name is easy to miss.
- Re-run it and read the output rather than watching for an exit code. Installers that fall back between download sources can print a warning that is easy to skim past. The standalone installers download from
releases.openai.comby default and fall back to GitHub Releases. - Prefer one install method and remove the others. Mixing a Homebrew install with an npm install in the same account is a reliable way to end up with two copies and confusing PATH results.
If it works by absolute path but not by name
The directory holding the binary needs to be on PATH for the shell that is failing.
- Find where your install method puts executables, then add that directory to the
PATHused by your shell’s startup file. - For an npm global install,
npm prefix -gprints the prefix directory whosebin(macOS/Linux) or root (Windows) holds global executables. Use that to locate what to add. - On Windows, a
PATHchange made in one place may not apply to a shell launched from another context. Set it in the environment the terminal actually inherits, then start a new terminal.
If you are in WSL
- Decide which side should run Codex. Running it inside the Linux distribution is the cleaner choice if your project lives there.
- Install inside that distribution, using the macOS/Linux standalone installer, and verify the first run offers a sign-in choice.
- Do not try to add a Windows executable to a Linux
PATH. It is possible with interop, but it is a support burden you do not need.
What not to do
- Do not run the installer with
sudoto “make it findable”. That installs for a different user and usually moves the problem rather than solving it. - Do not paste installer output containing tokens or account identifiers into a public issue.
- Do not add broad directories such as your home directory to
PATHto make one command resolve. That is how unrelated executables start shadowing system ones.
How to tell it worked
Running codex starts the client and offers a sign-in path, rather than returning a not-found error. In the documented first-run flow you are offered a choice including Sign in with ChatGPT. Reaching that prompt means the install and the PATH are both fine.
If it is still failing
If the command resolves and the client starts but the sign-in step fails, that is a different problem with a different set of causes. If it starts and then prints configuration warnings, look at the MCP startup path instead.
Known limits of this guidance
- Evidence level: documentary. The install methods are quoted from the official README as read on the review date; installer behaviour can change between releases.
- The PATH troubleshooting here is standard operating-system practice, not a claim taken from OpenAI documentation. It is presented as a method, not as an official instruction.
- Windows-specific
PATHediting differs between shells and system versions, so no single procedure is prescribed here. - This guide does not cover package-manager-specific failures, such as a proxy blocking npm.
Sources
Each source lists what it is used to support. Sources are re-read on the review schedule, not continuously.
Codex CLI README - Installing and running Codex CLI (openai/codex)
The documented install methods: the standalone shell installer for macOS and Linux, the PowerShell installer for Windows, npm install -g @openai/codex, and brew install --cask codex; that the command to start is codex; and that the standalone installers download from releases.openai.com by default with a GitHub Releases fallback.
Codex CLI README - Using Codex with your ChatGPT plan (openai/codex)
That a first run is expected to offer a sign-in choice, which is what distinguishes a successful launch from a missing install.
Related guides
How this page is checked
- Evidence level
- Documentary - supported by official documentation
- Last reviewed
- 2026-09-20
- Content updated
- 2026-09-20
- Full version scope
- Documented install methods as published in the official Codex CLI README. Installer behaviour can change between releases.
- Symptoms indexed
-
- The installer appeared to finish successfully
- Running codex in the terminal returns command not found or not recognized
- It works in one terminal and not another
Reviewer note
Built directly from the official README's documented install methods. The PATH troubleshooting approach is general operating-system knowledge, not a Codex-specific claim, and is labelled as such.