Repository navigation
fix(build): find npm when only npm.exe exists on Windows - #31
Merged
Merged
Conversation
On Windows, build.rs and cargo xtask always spawned `npm.cmd`. A Node install without that shim, like the nvm v2 one on a contributor machine that ships only `npm.exe`, failed with "program not found": `cargo build` stopped in build.rs, and `cargo xtask ci` stopped at its UI test step. SKIP_UI_BUILD=1 got past build.rs only. Use `npm.cmd` when a directory on PATH has it, and plain `npm` otherwise (which resolves to `npm.exe`). Installs that ship the `.cmd` shim, as on GitHub's Windows runners (unverified), keep the same behavior. build.rs cannot share code with xtask, so the small lookup exists in both; housekeeping.rs reuses the xtask one. Verified on the affected machine: `cargo build -p braid` without SKIP_UI_BUILD reran `npm ci` and the vite build and finished. The xtask copy was not run with an npm.exe-only install.
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.
On Windows,
cargo buildfails inbuild.rswith "program not found" when the Node install has nonpm.cmd. I hit it with nvm v2, which only shipsnpm.exe.cargo xtask cifails the same way at its UI test step, andcargo xtask housekeepingskips its npm checks with "needs Node.js / npm".SKIP_UI_BUILD=1only gets pastbuild.rs.build.rs, the xtask UI commands and the housekeeping npm checks all hardcodednpm.cmdon Windows. They now usenpm.cmdwhen a directory onPATHhas it, and plainnpmotherwise, which findsnpm.exe. Installs with the.cmdshim keep the same behavior.build.rscannot share code with xtask, so the small lookup is in both.housekeeping.rsreuses the xtask one.Test Plan
cargo build -p braidwithoutSKIP_UI_BUILDon a machine with onlynpm.exe:npm ciand the vite build ran and the build finishednpm.cmdpath and non-Windows)The xtask copy was not run on an
npm.exe-only install. It is the same code asbuild.rs.