When a Mac App Can't Find a CLI Your Terminal Can Run

By Rareș Gosman

A Mac GUI app and your terminal have different PATH environments. The app inherits from launchd, not your shell config, so the fix belongs there too.

macOSCLIPATHlaunchd

A Mac GUI app reported that codex was missing. My terminal ran codex --version fine. Both were on the same machine, logged in as the same user.

The problem was that the app and the terminal had different PATH environments. Finder and Dock launches inherit their environment from launchd, not from .zshrc, .zprofile, or nvm. My terminal had Homebrew and nvm on its PATH. The app had the bare Apple default:

/usr/bin:/bin:/usr/sbin:/sbin

That excludes /opt/homebrew/bin entirely. Codex was installed and runnable. The app just couldn't see it.

Debug the App, Not the Shell

Symlinks, reinstalls, and shell config changes are all distractions here. The app doesn't read your shell config. Instead, look at what the app process actually has:

ps eww -p <pid>

<pid> is the process ID of the running app. You can find it with pgrep, Activity Monitor, or any process-listing tool.

Then launch the app with an explicit path to confirm the diagnosis:

open --env PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin -a "LLM Wiki"

With that environment, the app found /opt/homebrew/bin/codex. So the problem was the app process environment, not the Codex install.

Fix the Launch Environment

For the current login session, launchctl setenv sets a path in launchd:

launchctl setenv PATH '/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

That wasn't enough for this app's normal service launch, which kept starting with the minimal Apple path.

For a durable fix, launchctl config sets the user-domain path across reboots:

sudo launchctl config user path '/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

macOS required a reboot to apply. After the reboot, Finder and Dock launches inherited the configured path, and the app found the Homebrew-managed codex at /opt/homebrew/bin/codex without any shell setup.

When a Mac app says a CLI tool is missing, ps eww -p <pid> shows you the PATH the app actually has. Start there.