Skip to content

Put a CLI's own bin directory first on its PATH, so an npm-installed codex can find node - #76

Open
AndrewYakovlev wants to merge 1 commit into
gsamat:masterfrom
AndrewYakovlev:fix/cli-path-beside-executable
Open

AndrewYakovlev wants to merge 1 commit into
gsamat:masterfrom
AndrewYakovlev:fix/cli-path-beside-executable

Conversation

@AndrewYakovlev

Copy link
Copy Markdown

Fixes #47.

When the app is opened normally, macOS gives it PATH=/usr/bin:/bin:/usr/sbin:/sbin. An npm-installed codex is a #!/usr/bin/env node script, so it exits with 127 even though Tooling finds it in /opt/homebrew/bin. Homebrew, nvm and mise all install node in the same bin directory as the CLI.

Subprocess.runSync now puts the executable's own directory first on the child's PATH. Both the --version probe and the real CLI runs go through Subprocess.runSync, so one change fixes both.

Tested with a new case in SubprocessTests: a #!/usr/bin/env script whose interpreter sits next to it. The test fails before the change and passes after it. The full swift test run passes, except MeetingLanguagesTests.restIsAlphabeticalAndUnique, which also fails on master on a Mac whose system language is Russian (localizedStandardCompare puts «Беларуская» before «Bosanski»).

I have not reproduced this on a machine with npm-installed Codex.

🤖 Generated with Claude Code

…codex finds the node beside it when amanu is launched as an app (gsamat#47).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

[Bug]: npm-installed Codex is found but cannot run from the macOS app

1 participant