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.

Error message

A macOS report in the Codex repository shows this exact shell output after an apparently successful package install:

zsh: command not found: codex

Other shells can phrase the same failure as codex: command not found or, in Windows Command Prompt, 'codex' is not recognized as an internal or external command. Those variants are shell messages, not Codex diagnostic codes. The linked reports document particular shells and installations; they do not prove one repair works everywhere.

Match the error to your shell

These messages point to command discovery, not a Codex account limit. The commands below are documented installation options only if no Codex executable exists in that same environment. If Codex runs by its absolute path, use the PATH checks in the next section instead of installing a second copy. After any install, open a new terminal and run codex --version in the shell that failed. The Codex CLI README documents the installers and the codex command.

Windows Command Prompt (cmd)

The reported cmd wording begins:

'codex' is not recognized as an internal or external command

If where codex finds nothing and npm is installed in Windows, install the CLI in that same Windows environment:

npm install -g @openai/codex

If npm itself is not found, first choose another documented installer rather than treating an npm error as a Codex error. If where codex finds a path, check that executable and your Command Prompt PATH before reinstalling.

Windows PowerShell

A Codex installation report shows this PowerShell line (the display may capitalize The):

codex : The term 'codex' is not recognized as the name of a cmdlet

If Get-Command codex -All finds nothing and npm is available in this PowerShell environment, the documented npm installation is:

npm install -g @openai/codex

An apparently successful winget or npm install can still leave the command unavailable. Reopen PowerShell and check its resolved path; do not assume that reinstalling changes a missing alias or PATH entry.

macOS or Linux bash

The site operator supplied this login-shell wording; other bash sessions may print a different prefix before the same codex: command not found text:

-bash: codex: command not found

If command -v codex finds nothing and you intend to install the CLI in this Unix environment, use the official standalone installer:

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

If it still fails, inspect the installer output and the directory it used. A Windows install does not install the Linux CLI inside WSL.

macOS or Linux zsh

The Codex repository report records the exact line:

zsh: command not found: codex

First run command -v codex. If the executable truly is missing from this environment, the official standalone installer is:

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

The linked case followed a Yarn installation; the error did not prove that its package was absent. If an executable exists under your original package manager, find that path and correct zsh command discovery instead of switching installers without checking.

When it happens

This page is for the CLI command after installation on Windows, macOS, Linux or WSL. It does not cover a desktop application that opens but fails to sign in, nor an IDE extension that reports an internal backend error. The shell looked for a command named codex and could not resolve one in its current environment. That result alone cannot tell whether installation never completed, the executable is outside PATH, or the command was installed in a different environment. The official README names the codex command and documents the supported installers.

The first distinction matters. If no executable exists, editing PATH will not install it. If the executable runs by its absolute path, reinstalling is unnecessary until you have checked where that shell searches. WSL has its own Linux environment and home; a Windows installation is not a Linux-native installation in your distribution. A terminal opened from an editor can also inherit an older environment than a newly opened terminal. These are operating-system diagnostic inferences, not a Codex-specific product promise.

Fix it step by step

  1. Identify the failing environment. Record whether the error came from PowerShell, Command Prompt, zsh, bash or WSL, and whether the project is in Windows or a WSL distribution. If you installed on Windows but the error occurs inside WSL, test the Windows command in a Windows terminal first. Choose one environment for the intended CLI and keep installation, configuration and diagnosis there.
  2. Start a new terminal and try once. Installers can update a user environment without changing an already-running shell. A fresh terminal is a cheap diagnostic. If codex opens there, no package reinstall is needed; make sure your editor terminal also starts with that environment. If it still fails, preserve the installer output rather than repeatedly invoking the same command.
  3. Ask the shell what it resolves. In PowerShell use Get-Command codex -All; in macOS/Linux/WSL use command -v codex. These commands do not modify files. An empty result says this shell cannot find the command by name. Multiple results mean the first path may shadow the installation you intended. Check the installation record, package manager and architecture before removing duplicates.
  4. Check the installation method, then locate its executable. The official README documents 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, and Homebrew brew install --cask codex. Look at the output from the method you actually used. For npm, npm prefix -g helps locate that Node environment’s global installation; it is only useful for npm, not a standalone or Homebrew binary. The old zsh issue used Yarn, so do not assume its package-manager path applies to your npm installation.
  5. If the executable exists, try its absolute path. A successful launch by absolute path shows that the program is present and the remaining failure is command discovery in this shell. Add only the directory that contains the verified executable to the appropriate PATH for this user and shell, then start another terminal. Do not put an entire home directory on PATH, copy a random executable into a system directory or set both Windows and WSL paths indiscriminately. A PATH change should target the environment that displays the error.
  6. If there is no executable, install in the intended environment. Re-run one documented install method and read its complete output, including a download fallback and any final error. The standalone installer normally uses releases.openai.com and can fall back to GitHub Releases according to the README. A warning followed by a successful install is different from a final command failure. If the installer itself fails, go to the update and installer failure guide with its exact error; a successful installer exit is not proof until the command resolves.
  7. Verify the result in the same shell. Run Get-Command codex -All or command -v codex again, then codex --version and finally codex. A version response confirms that this shell found a Codex executable. The official first-run flow offers a sign-in choice, but reaching it only verifies launch; it does not prove authentication or that a desktop app uses the same binary. If launch starts and then fails for another reason, stop treating it as a missing-command problem.

Still not working?

  • If the command works in a standard terminal but not an IDE terminal, compare their environment and restart the editor. Keep the exact shell and resolved path with the report; a generic reinstall can hide the difference.
  • If codex resolves to an older copy, compare that path with the installer or npm global prefix. Update or remove a duplicate through its own package manager only after you know which copy is active.
  • If the executable is present but won’t start, save the new error. Windows sandbox setup, login and MCP startup have different checks; command discovery is already solved.

FAQ

Why does a successful install still say command not found?

The package may have installed an executable outside this shell’s PATH, or into a different Windows, WSL or Node environment. An installer message and command discovery are separate checks. Locate the actual executable first; if it runs by absolute path, fix only the shell path.

Should I reinstall Codex to fix a PATH problem?

Not before locating the binary. If it runs by absolute path, reinstalling can create a second copy and make the launch path less clear. Record the active shell and install method, then add the verified executable directory to that environment’s path.

Is installing Codex on Windows enough for WSL?

No Linux-native CLI is thereby installed inside WSL. Windows interoperability may expose a Windows executable, but the two environments have different homes, paths and installation contexts. If you intend to work inside WSL, install and verify Codex in that distribution.

Compare another message in the Codex error guide library. First check whether this is a Codex service-side problem → View live Codex status.

Sources

Each source lists what it is used to support. Sources are re-read on the review schedule, not continuously.

How this page is checked
Evidence level
Documentary - supported by official documentation
Last reviewed
2026-10-19
Content updated
2026-10-19
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

Independently reviewed on 2026-10-19 against saved source snapshots after the shell-variant edit. The bash login-shell wording was supplied by the site operator and was not independently found in a public Codex issue; its prefix can vary. Installation commands are conditional when the executable is truly absent; an existing executable outside PATH needs a path correction instead.

Last updated: