fix: run the bundle build's npm spawn through npm's CLI entry point - #159
Open
AuroraAeon wants to merge 1 commit into
Open
AuroraAeon wants to merge 1 commit into
AuroraAeon wants to merge 1 commit into
Conversation
build-coding-agent-bundle.mjs spawns `execFileSync("npm", ...)`, which
fails on Windows: ENOENT because the npm.cmd shim is not resolved,
EINVAL when npm.cmd is passed without a shell, and with shell:true the
unquoted `--prefix <path>` argument splits on spaces in the repo path,
so ./test.sh cannot complete its build step from a fresh checkout.
Resolve npm's JS entry via npm_execpath (set by npm/pnpm lifecycle
scripts), falling back to the npm-cli.js beside node.exe and then to the
previous PATH spawn (shell-resolved on win32 only). POSIX behavior is
unchanged.
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
From a fresh Windows checkout,
./test.shcannot get past its build step:scripts/build-coding-agent-bundle.mjsspawns the app build withOn Windows this fails in every naive form, which I reproduced in order on Node v25.2.1:
As written upstream —
ENOENT:execFileSyncdoes not resolve thenpm.cmdshim throughPATHEXT."npm.cmd"—EINVAL: Node rejects spawning.cmdfiles without a shell (cmd-spawn hardening in recent Node releases).shell: true(the patternprofile-coding-agent-node.mjsuses) — cmd.exe receives the arguments unquoted, so--prefix <path>splits on the first space in the repo path:(That sibling script gets away with
shell: trueonly because its arguments are fixed tokens and workspace-relative paths without spaces;--prefixhere is an absolute path.)So the documented contribution gate (
npm run check+./test.sh) is unreachable on Windows, including for repo paths as ordinary as...\Default Project\Step-Code.Fix
Run npm's own CLI entry point through the current Node binary — no shell, no
.cmd, no quoting:Resolution order:
npm_execpath— set by npm (and pnpm) lifecycle scripts, i.e. every documented build entry point (build,build:offline,test.sh);npm-cli.jsbesidenode.exe— covers manualnode scripts/build-coding-agent-bundle.mjson the standard Windows installer;grepover*.{mjs,js,ts,mts}finds only this script andprofile-coding-agent-node.mjsspawningnpm/pnpm/npx; the latter's arguments are space-free relative paths and are intentionally left alone.Verification (Windows 11, Node v25.2.1, npm 11, pnpm 9.15.9, repo path contains a space)
git cloneinto...\Documents\Default Project\Step-Code→pnpm install --frozen-lockfile✅ exit 0.npm_execpath):node scripts/build-coding-agent-bundle.mjs✅ exit 0 — producesapps/cli/dist/main.jsandpackages/coding-agent/dist/bundle/step.js. This is the exact command and path that failed with all three error modes above.npm run build:offline(tier 1, lifecyclenpm_execpath) ✅.npm run check✅ exit 0 (also run by the pre-commit hook at commit time)../test.sh— the build step, which previously could not complete on Windows at all, now finishes; itstest:scriptsphase passes 34/34.pnpm -r --if-present test --no-bail, this branch vs cleanadcf37b):test/bash-close-hang-windows.test.tsonly in the fixed run,test/session-file-invalid.test.tsonly in the baseline) and both pass when re-run individually → flaky, not a regression;EACCESvsEPERM, ESMc:URL scheme, missingSIGCONT, repo path containing a space, …) that exist on cleanupstream/mainregardless of this change — same methodology as the baseline comparison in the discussion of fix: route search_web to the Step Plan MCP endpoint #158.Notes
npmshim would run, and the tier-3 fallback spawnsnpmdirectly without a shell exactly as today.existsSync,dirname, andjoinare already imported.