Install Codex CLI With Homebrew
Homebrew is one way to install the Codex CLI on macOS. This guide walks through the installation steps, authentication choices after install, and what to check if the setup does not work as expected.
Updated 4 min read
Homebrew is a popular package manager for macOS and Linux that makes it straightforward to install, update, and remove command-line tools. If you already use Homebrew for other tools, installing the Codex CLI through it keeps everything under one management system. If you prefer Node.js tools, the npm path works on any platform.
Installation gets the tool onto your machine. What the tool does when it runs depends on the project context it reads at the start of each session. A tool like fenbs keeps that context, including the project rules and current tasks, outside the CLI so any session can read it without a manual briefing.
Before you install
You need an OpenAI account with API access. Codex CLI makes API calls and each session uses tokens from your account. If you do not have an API key yet, create one at platform.openai.com before the install, so you can authenticate immediately after.
If you are installing on macOS, Xcode Command Line Tools must be present. Homebrew requires them. Install them with xcode-select --install if you have not already.
Check whether Homebrew itself is installed: run brew --version in your terminal. If it is not, install it from brew.sh first, then return to this guide.
Install Codex CLI with Homebrew
The Codex CLI may be available through the main Homebrew formulae or through an OpenAI tap. Check the OpenAI Codex repository (opens in a new tab) for the current Homebrew install command, because the exact formula name can change between releases. A typical install looks like:
brew install openai/tap/codex # or if available in the main formulae: brew install codex
If the install uses a tap, Homebrew will add the tap first and then install the formula. Follow any prompts during the install. When it finishes, confirm the install worked:
codex --version
Install with npm if you prefer
If you manage Node.js tools with npm or prefer a cross-platform install path, npm works on macOS, Linux, and Windows:
npm install -g @openai/codex
Run codex --version after install to confirm. If the command is not found, your npm global bin directory may not be on your PATH. Check with npm bin -g and add that directory to your shell's PATH.
The Homebrew and npm versions should be functionally equivalent; the main difference is how you update them later. With Homebrew: brew upgrade codex. With npm: npm install -g @openai/codex.
Authenticate after install
The two main authentication methods are codex auth and setting the OPENAI_API_KEY environment variable.
codex auth opens a browser sign-in, which is the simplest path for a personal machine. Run it once; the credential is stored locally. Every future codex run reads it automatically.
codex auth
For a server, a CI pipeline, or a shared machine where a browser sign-in is not practical, set the API key in your shell profile:
export OPENAI_API_KEY=your-key-here
See codex cli authentication for a full walkthrough of both methods, including how to handle account mismatches.
Check a fresh install
Run a simple task to confirm the end-to-end setup works:
codex "List the files in the current directory and describe what each one does"
If it runs and returns a response, the install and authentication are working. If it returns an API error, check that your key is set correctly and that the account has sufficient quota.
For codex cli on windows, the npm path is the standard route since Homebrew targets macOS and Linux.
Common install issues
command not found: codexafter install: the install directory is not on your PATH. For Homebrew, runbrew doctorto check. For npm, runnpm bin -gand add the result to your PATH.- Permission errors during install: do not use
sudowith Homebrew. For npm globals, set a user-writable npm prefix rather than running as root. - Outdated Homebrew formulae: run
brew updatebefore installing to make sure you get the current version of the formula. - API key not recognized: confirm the key is exported in the same shell where you run
codex. A key set in one terminal window is not visible in another unless it is in your shell profile.
Give the new assistant a project to start from
Once Codex CLI is installed and authenticated, connect it to fenbs over MCP from Integrations. Add your project with its current tasks and Decisions and rules. The next time you open a session, the assistant reads the project context before it does anything, so you brief it once and it works from that record every time after. Create a free account to get started.
Create a free accountFree for one person · No credit card · Works with Claude, ChatGPT, Cursor and more
Keep Codex CLI current
Codex CLI is updated regularly. New versions add model support, fix tool-calling behavior, and sometimes change flag names. Check the OpenAI Codex repository (opens in a new tab) for the latest release notes before starting a large project.
With Homebrew, update alongside your other tools by running brew update and brew upgrade on a regular schedule. With npm, reinstall the package globally to get the latest version. Running codex --version before a long session confirms you are on a recent release and avoids running into a fixed bug on an old version.
How to do this with fenbs
- Create a free account and add your first project. Write the goal, any standing rules, and the current tasks.
- Install and authenticate Codex CLI as described above.
- Connect Codex CLI to fenbs over MCP from Integrations. The sign-in is a browser flow separate from your OpenAI authentication.
- Open a Codex CLI session and ask it to read the project context from fenbs: rules first, then current tasks and Where we left off.
- Before the session ends, ask it to save progress. The next session on any machine picks up from the same point.