Skip to content

env: node: No such file or directory — Codex update failed

Quick fix

When CC Switch is launched from the Dock/Finder, the GUI PATH lacks the Homebrew directory; upgrading to v3.18.0+ fixes it.

Error output
env: node: No such file or directory
env: node: No such file or directory

When CC Switch is launched from Finder/Dock, the PATH inherited by the macOS GUI process is only /usr/bin:/bin:/usr/sbin:/sbin, which does not include /opt/homebrew/bin. The Codex and npm entry scripts use the #!/usr/bin/env node shebang, so even if CC Switch invokes /opt/homebrew/bin/codex or /opt/homebrew/bin/npm by absolute path, env still needs to resolve node through PATH, and node is not in the GUI PATH, causing the error. This issue is most common on Apple Silicon macOS with Homebrew-installed Node + Codex; version managers such as nvm/fnm/mise behave the same way. The fix in v3.18.0: all anchored npm calls (including the Codex update/repair path) first prefix PATH=<npm's sibling bin directory>:$PATH before execution, ensuring npm and the node resolved by the shebang come from the same installation directory, no longer depending on the GUI process's PATH.

  1. Upgrade CC Switch to v3.18.0 or later; this version automatically prepends the PATH before all anchored npm calls.

    # 无需手动修改配置文件,升级 cc-switch 即可
  2. If you cannot upgrade right now, launch CC Switch from a terminal that already includes /opt/homebrew/bin as a temporary workaround: run open -a "CC Switch" in Terminal or run the binary directly.

    # 临时绕过:从 Terminal 启动而非 Finder/Dock
  3. After upgrading, find the Codex local tool card in Settings / About, click update/upgrade again, and confirm the error no longer occurs.

    # 无配置变更
ToolCodex
Version3.16.2 - 3.16.4(受影响),v3.18.0 修复
PlatformsmacOS
Why does codex --version work in my terminal, but updating fails when CC Switch is launched from the Dock?
macOS GUI applications launched from Finder/Dock inherit a PATH that does not include /opt/homebrew/bin, while the codex/npm shebang script #!/usr/bin/env node depends on PATH to locate the node runtime. The terminal is a login shell that loads shell rc files to complete the PATH; GUI processes do not.
Do I still need to set the PATH manually after upgrading to v3.18.0?
No. v3.18.0 automatically prefixes PATH=<npm's sibling bin directory>:$PATH before every anchored npm call, so both npm and node resolve from the same installation directory, independent of the GUI process PATH.
Is the "cannot run" message for Codex on Windows the same problem?
No. Installing Codex globally via npm on Windows generates three files: an extensionless POSIX shim (codex), codex.cmd, and codex.ps1. Older CC Switch versions misidentified the extensionless shim as the default entry and marked it unusable. That is a different issue, fixed in v3.16.5; the detection logic now prioritizes the .cmd/.exe sibling files.

This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.