fix: resolve Node outside minimal hook PATH - #737
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f09814f4b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a17c3dafe4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| printf '%s\n' "$candidate" | ||
| return 0 |
There was a problem hiding this comment.
Keep searching for the toolchain that contains Codex
When the minimal PATH already contains a supported system Node but Codex was installed under nvm, fnm, Volta, or a custom npm prefix, this immediate return selects the system Node and line 58 only re-adds its directory. The enabled Stop hook then checks bare codex in getCodexAvailability(), reports it missing, and returns without running the review gate even though Codex is installed. Continue searching for a compatible toolchain containing the Codex executable, or separately restore Codex's install directory.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc0ffadc0e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /opt/homebrew/bin/node /usr/local/bin/node /opt/local/bin/node \ | ||
| "$home/.volta/bin/node" \ | ||
| "$home"/.nvm/versions/node/*/bin/node \ | ||
| "$home"/.local/share/fnm/node-versions/*/installation/bin/node \ | ||
| "$home"/.asdf/installs/nodejs/*/bin/node \ |
There was a problem hiding this comment.
Search standard Windows Node install locations
When Git Bash receives the same minimal PATH this launcher is intended to repair, a normal Windows Node installation under %ProgramFiles%\nodejs (or nvm-windows/Volta under %LOCALAPPDATA%) is not discoverable: the fallback list contains only Unix-style locations beneath $HOME. Consequently all three hooks and the deterministic commands still exit 127 for typical Windows installations unless users manually set CODEX_COMPANION_NODE; include the standard Windows locations or honor the relevant installation-root environment variables.
Useful? React with 👍 / 👎.
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
There is a version-manager edge here when node is absent from PATH and several nvm/fnm/asdf/mise installations exist. The glob loop selects the first supported executable in lexical path order, not the version manager's active/default runtime. That selected directory is then prepended to PATH, so a codex shim found later in another installation can still resolve #!/usr/bin/env node to the earlier, unrelated Node version. A machine with nvm v20 and v24 installed can therefore run the companion and Codex under a different runtime than the user's configured default. Resolving the manager's default/current alias first, or selecting the highest supported semantic version, would avoid that mismatch. A regression with two supported nvm installs and codex present only in the newer one would make the behavior explicit.
Summary
Fixes #105.
Claude Code hooks and
!-pattern commands can run with a minimal shellPATHthat does not include a user-installed Node binary. The plugin currently invokes barenodefrom SessionStart / SessionEnd / Stop and from/codex:status,/codex:result, and/codex:cancel, so those surfaces fail withcommand not found: nodeeven when Node is installed normally through Homebrew or a user-level version manager.This patch adds a small POSIX launcher under the plugin and routes only those affected surfaces through it.
The launcher resolves Node in this order:
CODEX_COMPANION_NODEnodealready onPATHEvery execution still targets the companion script under the current plugin root. Windows / Git Bash remains supported by normalizing
CLAUDE_PLUGIN_ROOTthroughcygpathat the command boundary.Validation
Windows 11 / Node 26.3.1 / Git Bash:
node, and the launcher did not existPATHand a synthetic nvm installation: PASS/codex:statuscommand: exit 0bash -n plugins/codex/scripts/run-node.shgit diff --checkFresh collision checks immediately before publication found no open PR implementing #105 or an equivalent minimal-PATH Node launcher.
Scope
Seven files only:
plugins/codex/scripts/run-node.shplugins/codex/hooks/hooks.jsonplugins/codex/commands/status.mdplugins/codex/commands/result.mdplugins/codex/commands/cancel.mdtests/commands.test.mjstests/node-launcher.test.mjsNo changes to review/rescue/setup routing or unrelated runtime behavior.