Skip to content

fix: properly use nodejs_jll on windows - #113

Merged
pfitzseb merged 1 commit into
mainfrom
sp/pagefind-node-cli
Aug 19, 2026
Merged

fix: properly use nodejs_jll on windows#113
pfitzseb merged 1 commit into
mainfrom
sp/pagefind-node-cli

Conversation

@pfitzseb

Copy link
Copy Markdown
Member

No description provided.

@asinghvi17 asinghvi17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable

NodeJS_22_jll exports `npm`/`npx` as FileProducts pointing at bin/npm and
bin/npx, but those are not the same kind of file on every platform:

- POSIX: the npm CLI's JavaScript, carrying a `#!/usr/bin/env node` shebang, so
  the kernel runs them directly. The command is unchanged from before, so there
  is nothing to regress there.
- Windows: bash scripts whose own header says they are "used by the Node.js
  installer, which expects the cygwin/mingw shell". CreateProcess cannot spawn
  those, so every pagefind build fails there with

      IOError: could not spawn `...\bin\npx pagefind -V`: unknown error (UNKNOWN)

Windows artifacts ship bin/npx.cmd alongside for exactly this, and a batch file
has to go through cmd.exe. Rather than a bare `cmd /c <path>`, which mis-parses
paths containing spaces, this uses the form Base documents for the purpose (see
Base.shell_escape_wincmd): `cmd.exe /S /C "<line>"` with windows_verbatim, where
/S makes cmd.exe strip the outer quote pair and take the rest verbatim. So

    cmd.exe /S /C ""C:\Users\John Doe\bin\npx.cmd" pagefind -V"

reaches the program with its quoting intact. windows_verbatim is what stops Julia
from re-quoting the line we assembled ourselves. Note that cmd.exe expands %VAR%
before any escaping is considered, so a % in an argument can still corrupt the
command line; none of the paths involved normally contain one.

Arguably NodeJS_22_jll should point at the .cmd on Windows itself -- the artifact
ships it -- but this does not wait on that being fixed upstream.

The pagefind run now also uses dir = root, like the version probe and the install
already did, so npx resolves pagefind from the node_modules that
`npm install pagefind` populated rather than from the ambient working directory.

Verified on Linux: a full PageFind build indexes and writes its output, and
`npm install pagefind` followed by the npx probe both succeed. The command each
platform builds is unit tested, gated on the platform that can run it, so the
Windows assertions need Windows CI to execute.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@pfitzseb
pfitzseb force-pushed the sp/pagefind-node-cli branch from c41c429 to c997b13 Compare August 19, 2026 15:48
@pfitzseb

Copy link
Copy Markdown
Member Author

Should probably add the *.cmd products to the jlls on Windows, if possible.

@pfitzseb
pfitzseb merged commit 522edc3 into main Aug 19, 2026
11 checks passed
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.

2 participants