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.
Symptom
Section titled “Symptom”env: node: No such file or directory
env: node: No such file or directoryWhen 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.
Upgrade CC Switch to v3.18.0 or later; this version automatically prepends the PATH before all anchored npm calls.
# 无需手动修改配置文件,升级 cc-switch 即可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/DockAfter upgrading, find the Codex local tool card in Settings / About, click update/upgrade again, and confirm the error no longer occurs.
# 无配置变更
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 7 real issues
- #4162[Bug] macOS tool update fails with `env: node: No such file or directory` when launched from Finder/Dock
- #4207[Bug] Windows 下将 npm 无后缀 codex shim 误判为默认入口
- #5684切换智能体环境导致项目对话消失
- #83wsl
- #4777Windows 环境下通过 npm 安装的 Codex 被错误识别为多处安装
- #6975CC Switch periodically wakes WSL2 when claudeConfigDir points to \\wsl.localhost, even when Claude Code is not in use
- #6708切换模型供应商以后显示 当前会话未提供可用的终端/文件操作工具
- 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.
Related problems
Section titled “Related problems”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.