Why Standard Uninstall Methods Often Fail With Codex
If you’ve dragged Codex to the Trash, run npm uninstall -g, or clicked “Uninstall” in Windows and the CLI still answers when you type codex --version, you’re not dealing with a broken uninstaller — you’re dealing with an architecture problem. Codex ships through at least four independent channels: a standalone binary dropped into your PATH, an npm global package, a Homebrew formula on macOS, or the Microsoft Store on Windows. None of these methods are aware of each other, and none coordinate cleanup with the desktop app.
The desktop GUI and the CLI tool are partially decoupled components. Removing the app often leaves the CLI binary untouched in a directory like /usr/local/bin or %USERPROFILE%\AppData\Local\Programs, which is why the terminal still responds after you thought you’d wiped everything. Conversely, uninstalling the npm package can strip the CLI but leave the desktop application and its Electron cache sitting in hidden directories.
Common symptoms of incomplete removal: the CLI returning command not found errors that reappear after a terminal restart, conflicts where another AI coding assistant refuses to bind to a port Codex is still holding, or cryptic Node.js module errors when the global binary points to a now-missing dependency. This isn’t user error — it’s the predictable result of a multi-path installation model that, according to GitHub issue threads, has tripped up developers cleaning up trial installations or troubleshooting toolchain conflicts.
Identify Your Codex Installation Method Before You Start
Nothing wastes more time than following removal steps for the wrong installation method. Before you delete a single file, run these diagnostics to confirm exactly how Codex arrived on your machine.
Check for an npm global install
If you installed the Codex CLI through npm, this command will reveal it immediately:
npm list -g --depth=0 | grep codex Any output means npm is managing that installation. If the command returns nothing, npm is not the culprit.
Check for a Homebrew install (macOS/Linux)
Homebrew users can verify with:
brew list | grep codex A match here tells you Homebrew controls the binary — skip the npm and manual removal sections entirely.
Locate a standalone binary
On macOS and Linux, which codex returns the active binary path. On Windows, use where codex from Command Prompt or PowerShell. If the path points somewhere like /usr/local/bin or ~/.local/bin, you’re dealing with a manual binary install rather than a package manager.
Identify a Microsoft Store installation (Windows)
Open Settings > Apps > Installed apps and search for “Codex,” or run this in PowerShell:
Get-AppxPackage | Where-Object {$_.Name -like "*Codex*"} A result here means the Store handles removal — not npm, not an uninstaller executable. Match your method, then jump to the corresponding section.
How to Uninstall Codex Installed via npm
If you’ve typed npm uninstall -g codex and watched it silently exit with no confirmation — then typed codex in your terminal and seen it still respond — you’re not imagining things. The npm uninstall path for Codex has tripped up plenty of developers, usually for one of two reasons: the package name is slightly different than you’d guess, or permission errors blocked the removal without throwing an obvious error.
The correct primary command is:
npm uninstall -g @anthropic/codex
The @anthropic/ scope is part of the package name, and omitting it is the most common reason the command appears to succeed while the binary stays right where it was. Run that exact command first.
When permission errors get in the way
If you see an EACCES error, resist the urge to slap sudo on the front. That approach can leave your global node_modules directory with mixed ownership, creating a cascade of permission headaches for other packages later. Instead, identify where your global packages live:
npm root -g
If that path sits inside a system-owned directory like /usr/local/lib/node_modules, you have two clean options: reconfigure npm to use a user-owned prefix (the npm docs recommend ~/.npm-global), or temporarily fix ownership on the existing directory with chown so the uninstall can proceed without elevated privileges.
Clearing the leftovers
Even after a successful uninstall, npm’s cache and the global node_modules folder can hold onto remnants. Clear the cache with:
npm cache clean --force
Then manually check your global node_modules path for any lingering @anthropic/codex directory and delete it if found. Finally, verify removal with which codex — if it returns nothing, you’re clean. If it still points to a binary, that binary likely came from a separate installation method (Homebrew, a standalone download, or the Microsoft Store), which you’ll need to address with that method’s removal steps.
How to Uninstall Codex Installed via Homebrew on macOS
If Codex is still responding in your terminal after you thought you’d removed it, you’re probably dealing with a Homebrew installation that standard npm uninstall commands won’t touch. The exact removal command depends entirely on whether you installed Codex as a regular formula or a cask — and getting that wrong is what causes the “uninstall failed silently” frustration.
First, determine your installation type by running brew list | grep codex. If it appears without –cask flags, use:
brew uninstall codex
If you installed the desktop GUI version, you’ll need:
brew uninstall –cask codex
Once the package is removed, don’t skip the cleanup step. Run brew cleanup to purge orphaned dependencies that Homebrew no longer needs — these leftovers are a common source of cryptic conflicts with other developer tools later.
Homebrew won’t touch user-specific application data, so manually check two directories next: ~/Library/Application Support/Codex and ~/Library/Caches/Codex. Delete both if they exist. Finally, verify that no dangling symlinks remain in your Homebrew binary path. For Intel Macs, check /usr/local/bin; for Apple Silicon, check /opt/homebrew/bin. Look for any codex or codex-cli symlinks and remove them with rm. This last verification is what prevents that maddening moment when your shell still autocompletes a command you were certain you’d erased.
How to Uninstall Codex Standalone Binary on Linux and Windows
If you installed Codex by grabbing a standalone binary, you’re in the messiest cleanup scenario — no package manager tracked where files landed, and the developer documentation rarely covers the full trail of artifacts the binary leaves behind. Removal is manual but straightforward once you know every hiding spot.
Step 1: Find and Delete the Binary
Open a terminal and run which codex (Linux) or where codex (Windows PowerShell). This returns the exact path — something like /usr/local/bin/codex or C:\Users\YourName\AppData\Local\Programs\codex\codex.exe. Delete that file directly with sudo rm /path/to/codex on Linux or by navigating to the folder and removing it on Windows. If which returns nothing, you may have renamed the binary or placed it somewhere unconventional — check any custom directories you’ve added to your $PATH.
Step 2: Purge Hidden Config and Data Directories
The binary is only half the story. Codex stores user-level configuration and cached data in locations most uninstall guides skip:
- Linux:
~/.codex/,~/.config/codex/, and occasionally~/.local/share/codex/. Runrm -rf ~/.codex ~/.config/codex ~/.local/share/codexto wipe all three. - Windows:
%APPDATA%\Codexand%LOCALAPPDATA%\codex. Paste those paths into File Explorer’s address bar and delete the folders.
Step 3: Clean Up Shell References and Background Services
If you added the binary’s location to your PATH manually, hunt down the export line in ~/.bashrc, ~/.zshrc, or your PowerShell profile ($PROFILE) and remove it. Leaving a dangling PATH entry won’t break anything, but it’s sloppy and can cause confusion later. If you ever configured Codex to run as a background daemon, check for leftover systemd user services with systemctl --user list-unit-files | grep codex and disable any matches before deleting the service file from ~/.config/systemd/user/.
How to Uninstall Codex from Microsoft Store on Windows
Microsoft Store apps don’t use the standard Windows installer system, which means the usual “Uninstall” button in Control Panel won’t always do the job cleanly. The Store version of Codex installs as an AppX package, sandboxed in a way that can leave behind configuration directories and registry-like state even after you think you’ve removed it.
Standard Removal (Start Here)
Open Settings > Apps > Installed apps, search for “Codex,” click the three-dot menu, and select Uninstall. If this works and you confirm no CLI commands remain responsive after a terminal restart, you’re done. If not — or if the entry refuses to disappear — move to PowerShell.
Force Removal via PowerShell
Run PowerShell as Administrator and execute:
Get-AppxPackage *codex* | Remove-AppxPackage
This bypasses the GUI and forcibly removes the package registration. For system-wide installs that were provisioned for all users, also run:
Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -match “codex”} | Remove-AppxProvisionedPackage -Online
Clearing Leftover Data
Even after package removal, user data often survives in two locations. Delete %LOCALAPPDATA%\Packages\ subfolders matching the Codex publisher name, and check %APPDATA%\Codex for orphaned configuration files. If the app still appears in your Start menu after a reboot, the provisioned package removal step was likely skipped — repeat it and restart.
What to Do When Codex CLI Still Responds After Uninstall
There’s a uniquely sinking feeling when you’ve run every uninstall command you can find, yet typing codex still spits out a response. You haven’t broken your machine — you’ve stumbled into a phantom executable, and the fix is methodical, not magical.
1. Clear Your Shell’s Memory First
Your shell caches the locations of executables, so even after deleting a binary, the cached path can persist. On Unix-like systems (macOS, Linux), run hash -r to flush that cache immediately. On Windows, closing and reopening your terminal achieves the same result. Skip this step and you’ll chase ghosts that don’t exist on disk.
2. Hunt Down Multiple Installations
This is the most common culprit. You may have installed Codex via npm globally, forgotten about a Homebrew version, or pulled a Docker image months ago. Run which -a codex (Unix) or where codex (Windows) to list every matching executable on your PATH. You’ll often find a binary lurking in ~/.local/bin, /usr/local/sbin, or a Node.js global prefix you don’t normally use. Remove each one individually.
3. Check Running Containers
If you ever experimented with a containerized Codex setup, a running instance can intercept your CLI calls. Run docker ps to spot any active containers, then docker images | grep codex to find cached images. Stop and remove anything that surfaces — these can survive system reboots and standard uninstalls without a trace in your local package manager.
Verification Checklist
After clearing each suspect, open a fresh terminal and run codex --version. If you get a “command not found” error, you’ve won. If not, inspect your $PATH variable manually — shadow directories earlier in the chain will always take priority, and finding them is a matter of elimination, not luck.
