BuildWithMatija
Get In Touch
  1. Home
  2. Blog
  3. Tools
  4. Fix & Install Codex CLI on macOS with Homebrew — v0.111.0

Fix & Install Codex CLI on macOS with Homebrew — v0.111.0

Step-by-step Homebrew troubleshooting to resolve 'zsh: command not found', reinstall Codex v0.111.0 and test GPT-5.4…

6th March 2026·Updated on:6th April 2026·MŽMatija Žiberna·
Tools
Fix & Install Codex CLI on macOS with Homebrew — v0.111.0

📚 Get Practical Development Guides

Join developers getting comprehensive guides, code examples, optimization tips, and time-saving prompts to accelerate their development workflow.

No spam. Unsubscribe anytime.

Related Posts:

  • •Fix Claude Code Auto Update Failed on Mac (ENOTEMPTY npm Error)
  • •OAuth for MCP Server: Complete Guide to Protecting Claude

If you installed the Codex CLI on a Mac using Homebrew and see zsh: command not found: codex, the installation likely created a broken symlink or an empty cask directory. This guide shows how to fix it and update to the latest Codex CLI version (v0.111.0) to test GPT-5.4 medium.

This walkthrough applies to MacBook systems using Apple Silicon or Intel with Homebrew installed.


Step 1: Check if Codex Is Installed

First confirm whether Homebrew installed the Codex cask.

brew list --cask | grep codex

If installed, you should see:

codex

Then check details:

brew info --cask codex

Typical output:

codex ✔: 0.111.0
OpenAI's coding agent that runs in your terminal
Artifacts
codex-aarch64-apple-darwin -> codex (Binary)

This means Homebrew should create a binary named codex.


Step 2: Verify the Codex CLI Binary

Check if the executable exists.

which codex

Expected result:

/opt/homebrew/bin/codex

If you see:

zsh: command not found: codex

the binary is missing or the symlink is broken.


Step 3: Inspect the Codex Installation Folder

Homebrew installs casks here:

/opt/homebrew/Caskroom

Check the Codex directory:

ls /opt/homebrew/Caskroom/codex/0.111.0

If the directory is empty, the archive download or extraction failed.

This is a known Homebrew issue where the binary symlink exists but the artifact was never extracted.


Step 4: Verify the Codex Symlink

Check the Homebrew binary symlink.

ls -l /opt/homebrew/bin/codex

Example output:

/opt/homebrew/bin/codex -> /opt/homebrew/Caskroom/codex/0.111.0/codex-aarch64-apple-darwin

If the target file does not exist, the installation is incomplete.


Step 5: Clean the Broken Codex Installation

Remove the existing cask and broken files.

brew uninstall --cask codex
rm -rf /opt/homebrew/Caskroom/codex
rm -f /opt/homebrew/bin/codex

This clears the corrupted installation.


Step 6: Reinstall Codex CLI on macOS

Install the latest version again using Homebrew.

brew install --cask codex

You should see:

Linking Binary 'codex-aarch64-apple-darwin' to '/opt/homebrew/bin/codex'
codex was successfully installed

Step 7: Verify Codex CLI Works

Run:

codex --help

You should see the Codex CLI help output with commands such as:

  • exec
  • review
  • apply
  • login
  • sandbox
  • resume

This confirms the CLI is correctly installed.


Step 8: Login to Codex

Authenticate with your OpenAI account.

codex login

Once authenticated, the CLI can run coding tasks directly from your terminal.


Step 9: Test Codex with GPT-5.4 Medium

You can run a prompt using the model flag.

Example:

codex -m gpt-5.4-medium "explain this repository"

Or start an interactive session:

codex

Codex will analyze the current repository and help generate code, run commands, or review changes.


Step 10: Run Codex for Code Review

Inside a Git repository you can run:

codex review

This performs an automated code review on the project.


Step 11: Apply Generated Code Changes

If Codex proposes modifications, apply them using:

codex apply

This runs git apply on the generated patch.


Recommended Codex CLI Settings

To allow Codex to modify files inside your workspace safely:

codex --sandbox workspace-write

For automatic command execution inside the project sandbox:

codex --full-auto

Avoid using full system access unless necessary.


Common macOS Codex Installation Issues

Codex Command Not Found

Cause Broken Homebrew symlink or missing artifact.

Fix Remove the cask directory and reinstall.


Empty Caskroom Folder

Cause Cached archive prevented extraction.

Fix Remove the Caskroom directory and reinstall.


Homebrew Path Missing

Ensure /opt/homebrew/bin exists in your PATH.

Check with:

echo $PATH

Final Result

After reinstalling, the Codex CLI should work from the terminal and support:

  • repository analysis
  • automated code review
  • patch generation
  • sandboxed command execution
  • testing GPT-5.4 medium from the command line

You now have a working Codex CLI setup on macOS.

📄View markdown version
0

Frequently Asked Questions

Comments

Leave a Comment

Your email will not be published

Stay updated! Get our weekly digest with the latest learnings on NextJS, React, AI, and web development tips delivered straight to your inbox.

10-2000 characters

• Comments are automatically approved and will appear immediately

• Your name and email will be saved for future comments

• Be respectful and constructive in your feedback

• No spam, self-promotion, or off-topic content

No comments yet

Be the first to share your thoughts on this post!

Matija Žiberna
Matija Žiberna
Full-stack developer, co-founder

I'm Matija Žiberna, a self-taught full-stack developer and co-founder passionate about building products, writing clean code, and figuring out how to turn ideas into businesses. I write about web development with Next.js, lessons from entrepreneurship, and the journey of learning by doing. My goal is to provide value through code—whether it's through tools, content, or real-world software.

You might be interested in

Fix Claude Code Auto Update Failed on Mac (ENOTEMPTY npm Error)
Fix Claude Code Auto Update Failed on Mac (ENOTEMPTY npm Error)

30th September 2025

OAuth for MCP Server: Complete Guide to Protecting Claude
OAuth for MCP Server: Complete Guide to Protecting Claude

7th December 2025

Table of Contents

  • Step 1: Check if Codex Is Installed
  • Step 2: Verify the Codex CLI Binary
  • Step 3: Inspect the Codex Installation Folder
  • Step 4: Verify the Codex Symlink
  • Step 5: Clean the Broken Codex Installation
  • Step 6: Reinstall Codex CLI on macOS
  • Step 7: Verify Codex CLI Works
  • Step 8: Login to Codex
  • Step 9: Test Codex with GPT-5.4 Medium
  • Step 10: Run Codex for Code Review
  • Step 11: Apply Generated Code Changes
  • Recommended Codex CLI Settings
  • Common macOS Codex Installation Issues
  • Codex Command Not Found
  • Empty Caskroom Folder
  • Homebrew Path Missing
  • Final Result
On this page:
  • Step 1: Check if Codex Is Installed
  • Step 2: Verify the Codex CLI Binary
  • Step 3: Inspect the Codex Installation Folder
  • Step 4: Verify the Codex Symlink
  • Step 5: Clean the Broken Codex Installation
Build With Matija Logo

Build with Matija

Modern websites, content systems, and AI workflows built for long-term growth.

Services

  • Headless CMS Websites
  • Next.js & Headless CMS Advisory
  • AI Systems & Automation
  • Website & Content Audit
  • Resources

    • Case Studies
    • How I Work
    • Blog
    • CMS Hub
    • E-commerce Hub
    • Dashboard

    Headless CMS

    • Payload CMS Developer
    • CMS Migration
    • Payload vs Sanity
    • Payload vs WordPress
    • Payload vs Contentful

    Get in Touch

    Ready to modernize your stack? Let's talk about what you're building.

    Book a discovery callContact me →
    © 2026BuildWithMatija•All rights reserved