fix(bin): distinguish ENOENT from other spawn failures#23
Merged
code-yeongyu merged 1 commit intoJun 5, 2026
Merged
Conversation
When the user's PATH is missing `npx` (Node.js not installed or npx-only PATH stripped), the bin script used to print a generic syscall error like "spawnSync npx ENOENT" with no hint about what to do. Branch on `err.code === "ENOENT"` to print a clear message pointing at the Node.js install page, and leave all other error codes on the existing syscall message. Adds a test (test/bin-spawn-error.test.mjs) that runs the bin with PATH=empty and asserts the new stderr text.
Owner
|
Verified the PR-specific test locally with |
Contributor
Author
|
Thanks for the careful review and the merge, @code-yeongyu 🙌 If you run into a similar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bin/lazycodex-ai.jsshells out tonpxviaspawnSync. When the user'sPATHis missingnpx(no Node.js installed, or a sandboxed environment that strips npx), the existing code prints the raw syscall error and exits 1. The error gives no hint that the actual problem is a missingnpx, and no hint about what to do (install Node.js).What changed
result.error.code === "ENOENT"inbin/lazycodex-ai.jsand print"npx not found on PATH. Install Node.js 20+ from https://nodejs.org."in that case.result.error.messageprint.test/bin-spawn-error.test.mjsto assert the new behavior. Test runs the bin withPATH=""to force ENOENT, captures stderr, and asserts the message mentionsnpxandNode.js. Test passes locally withnode --test test/*.test.mjs.Why this fits
Tiny, focused, no behavior change for valid input. Matches the style of the existing bin script (no external deps, plain Node).
Test
Manual:
No related issue — this is a clear UX gap observed by running the bin in a fresh container.
Summary by cubic
Improve bin error message when
npxis not on PATH by detectingENOENTand guiding users to install Node.js 20+. Adds a test to verify the behavior.ENOENTfromspawnSyncand print "npx not found on PATH. Install Node.js 20+ from https://nodejs.org."; other errors stay the same.test/bin-spawn-error.test.mjsto run with emptyPATH, asserting the message and exit code 1.Written for commit d40a0cb. Summary will update on new commits.