Skip to content

fix: resolve Node outside minimal hook PATH - #737

Open
fscfede-beep wants to merge 4 commits into
openai:mainfrom
fscfede-beep:fix/portable-node-launcher-105
Open

fix: resolve Node outside minimal hook PATH#737
fscfede-beep wants to merge 4 commits into
openai:mainfrom
fscfede-beep:fix/portable-node-launcher-105

Conversation

@fscfede-beep

Copy link
Copy Markdown

Summary

Fixes #105.

Claude Code hooks and !-pattern commands can run with a minimal shell PATH that does not include a user-installed Node binary. The plugin currently invokes bare node from SessionStart / SessionEnd / Stop and from /codex:status, /codex:result, and /codex:cancel, so those surfaces fail with command not found: node even 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:

  • explicit CODEX_COMPANION_NODE
  • node already on PATH
  • common Homebrew / MacPorts locations
  • Volta
  • nvm
  • fnm
  • asdf
  • mise

Every execution still targets the companion script under the current plugin root. Windows / Git Bash remains supported by normalizing CLAUDE_PLUGIN_ROOT through cygpath at the command boundary.

Validation

Windows 11 / Node 26.3.1 / Git Bash:

  • test-first regression: hooks / deterministic commands still used bare node, and the launcher did not exist
  • launcher regression with an empty PATH and a synthetic nvm installation: PASS
  • commands + launcher + process + state regressions: 15 passed, 0 failed
  • SessionStart / SessionEnd lifecycle regressions: 2 passed, 0 failed
  • literal execution of the generated SessionStart hook command: exit 0
  • literal execution of the generated /codex:status command: exit 0
  • bash -n plugins/codex/scripts/run-node.sh
  • hooks JSON parse check
  • git diff --check

Fresh 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.sh
  • plugins/codex/hooks/hooks.json
  • plugins/codex/commands/status.md
  • plugins/codex/commands/result.md
  • plugins/codex/commands/cancel.md
  • tests/commands.test.mjs
  • tests/node-launcher.test.mjs

No changes to review/rescue/setup routing or unrelated runtime behavior.

@fscfede-beep
fscfede-beep requested a review from a team September 5, 2026 01:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread plugins/codex/scripts/run-node.sh
Comment thread plugins/codex/scripts/run-node.sh

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +29 to +30
printf '%s\n' "$candidate"
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +35 to +39
/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 \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 sylvesterkaczmarek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex plugin commands fail with command not found: node on Mac App

2 participants