fix(scripts): make add-lang bench scripts work on Windows#1246
Open
bslatner wants to merge 1 commit into
Open
Conversation
verify-extraction.mjs hard-coded execFileSync('codegraph', ...), which is
ENOENT on Windows: CreateProcess does no PATHEXT resolution, and npm ships
CLIs only as .cmd / sh / .ps1 shims (no .exe), none of which Node can spawn
without a shell. That forced FORCE_AB=1 workarounds to get past a phantom
extraction failure.
- verify-extraction.mjs: resolve the binary — CODEGRAPH_BIN env var first
(.js/.mjs/.cjs run via process.execPath), else on win32 scan PATH for the
.cmd/.exe/.bat shim and run batch shims through the shell with self-quoted
args (Node does not escape when shell is enabled). POSIX default path is
unchanged. Failure now exits 2 with a CODEGRAPH_BIN hint instead of a raw
ENOENT.
- bench.sh: honor CODEGRAPH_BIN via a codegraph() function shadowing the
PATH lookup, exported so the verify-extraction.mjs child resolves the
same binary. Unset-env behavior is unchanged.
Validated on Windows 11 (Git Bash + PowerShell): env-var override, .cmd
shim resolution with spaces in both shim dir and repo path, graceful
no-binary failure, and a full bench.sh clone->index->verify->skip-A/B run.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
scripts/add-lang/verify-extraction.mjshard-codesexecFileSync('codegraph', ...), which always fails withENOENTon Windows:CreateProcessdoes no PATHEXT resolution, and npm exposes CLIs on Windows only as.cmd/ extensionless-sh /.ps1shims — none of which Node can spawn without a shell (spawning a.cmdwithoutshell: trueis even a hardEINVALsince the CVE-2024-27980 fix). The phantom "could not read codegraph status" failure then forcesFORCE_AB=1workarounds inbench.shto get past a perfectly healthy extraction.This bites anyone running the
/add-langbench flow on Windows, regardless of how Node is installed.Fix
verify-extraction.mjs— resolve the binary instead of assuming a bare name works:CODEGRAPH_BINenv var takes priority everywhere; a.js/.mjs/.cjspath runs viaprocess.execPath.PATHfor thecodegraph.cmd/.exe/.batshim; batch shims run through the shell with self-quoted args (Node doesn't escape whenshellis enabled), so paths with spaces survive.CODEGRAPH_BINhint instead of a raw ENOENT.bench.sh— honorCODEGRAPH_BINvia acodegraph()function that shadows the PATH lookup (routing.jspaths throughnode), exported so theverify-extraction.mjschild resolves the same binary. Behavior with the env var unset is unchanged.Validation (Windows 11, Git Bash + PowerShell, real runs)
CODEGRAPH_BIN=dist/bin/codegraph.js→ verify reads status,RESULT: PASS, exit 0..cmdshim on PATH, no env var → resolved and passed, including a shim dir and repo path containing spaces (the exact case that previously died with ENOENT).bench.shrun under Git Bash (env-var and shim-pair variants): clone → wipe+index → verify → correctly skips the paid A/B on a deliberate critical failure, exit code propagated.bash -nclean; POSIX default paths are unchanged by inspection (only error-message text gained a hint).🤖 Generated with Claude Code