[GH-ISSUE #3162] Windows: staging server build fails with 'C:\Program' is not recognized (unquoted process.execPath through cmd shell in packages/server/scripts/build.mjs) #1697

Closed
opened 2026-10-21 05:41:48 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Jul 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3162

Originally assigned to: @kolacheee on GitHub.

Summary

On staging, pnpm check (and pnpm build) fails on Windows whenever Node.js is installed in a path containing a space — which is the default installer location, C:\Program Files\nodejs. The server package build aborts with:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Root cause

packages/server/scripts/build.mjs (introduced in #3157) runs its final step as:

run(process.execPath, [resolve(__dirname, "write-build-meta.mjs")]);

where the run() helper calls spawnSync with shell: process.platform === "win32". With shell: true, Node concatenates the command and args into a single unquoted cmd.exe /c line, so C:\Program Files\nodejs\node.exe is split at the space and cmd tries to execute C:\Program. Node 22+ even emits DEP0190 warning about exactly this pattern.

The script-path argument has the same exposure: if the repo is cloned under a directory with a space in it, the unquoted arg breaks identically even when Node itself lives in a space-free path.

Reproduction

On any Windows machine with Node under C:\Program Files\nodejs:

node -e "const {spawnSync}=require('child_process'); const r=spawnSync(process.execPath,['-e','console.log(1)'],{shell:true,stdio:'inherit'}); console.log('status:', r.status)"

Output:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
status: 1

Or simply run pnpm check on staging — the server build step exits non-zero after tsc completes.

Scope check (other call sites)

I swept the other spawnSync/execFile call sites on staging for the same pattern:

  • packages/client/scripts/build.mjs — same run() helper, but only invokes tsc / vite, which are bare .cmd shim names that genuinely need shell: true on Windows. Not affected.
  • packages/server/scripts/write-build-meta.mjs, scripts/check-tracked-installers.mjs — invoke bare git with the shell. Works; unaffected.
  • packages/server/scripts/run-tests.mjs, scripts/check-impeccable-context.mjs — already spawn process.execPath without a shell, which is the correct pattern.

So the fix is confined to the one call in packages/server/scripts/build.mjs.

Suggested fix

Spawning node.exe directly needs no shell (it's a real executable, not a .cmd shim). Let run() accept a per-call shell override and pass shell: false for the write-build-meta.mjs invocation. This also fixes the spaced-repo-path case, since without a shell the args are passed verbatim.

Environment

  • Windows 11 Pro (10.0.26200), Node.js in C:\Program Files\nodejs
  • Branch: staging (bug is not on main — packages/server/scripts/build.mjs only exists on staging)

Taking this one myself — small fix PR against staging to follow shortly. (owner: @kolacheee)

Originally created by @kolacheee on GitHub (Jul 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3162 Originally assigned to: @kolacheee on GitHub. ## Summary On `staging`, `pnpm check` (and `pnpm build`) fails on Windows whenever Node.js is installed in a path containing a space — which is the default installer location, `C:\Program Files\nodejs`. The server package build aborts with: ``` 'C:\Program' is not recognized as an internal or external command, operable program or batch file. ``` ## Root cause `packages/server/scripts/build.mjs` (introduced in #3157) runs its final step as: ```js run(process.execPath, [resolve(__dirname, "write-build-meta.mjs")]); ``` where the `run()` helper calls `spawnSync` with `shell: process.platform === "win32"`. With `shell: true`, Node concatenates the command and args into a single unquoted `cmd.exe /c` line, so `C:\Program Files\nodejs\node.exe` is split at the space and cmd tries to execute `C:\Program`. Node 22+ even emits `DEP0190` warning about exactly this pattern. The script-path argument has the same exposure: if the repo is cloned under a directory with a space in it, the unquoted arg breaks identically even when Node itself lives in a space-free path. ## Reproduction On any Windows machine with Node under `C:\Program Files\nodejs`: ``` node -e "const {spawnSync}=require('child_process'); const r=spawnSync(process.execPath,['-e','console.log(1)'],{shell:true,stdio:'inherit'}); console.log('status:', r.status)" ``` Output: ``` 'C:\Program' is not recognized as an internal or external command, operable program or batch file. status: 1 ``` Or simply run `pnpm check` on `staging` — the server build step exits non-zero after `tsc` completes. ## Scope check (other call sites) I swept the other `spawnSync`/`execFile` call sites on `staging` for the same pattern: - `packages/client/scripts/build.mjs` — same `run()` helper, but only invokes `tsc` / `vite`, which are bare `.cmd` shim names that genuinely need `shell: true` on Windows. Not affected. - `packages/server/scripts/write-build-meta.mjs`, `scripts/check-tracked-installers.mjs` — invoke bare `git` with the shell. Works; unaffected. - `packages/server/scripts/run-tests.mjs`, `scripts/check-impeccable-context.mjs` — already spawn `process.execPath` **without** a shell, which is the correct pattern. So the fix is confined to the one call in `packages/server/scripts/build.mjs`. ## Suggested fix Spawning `node.exe` directly needs no shell (it's a real executable, not a `.cmd` shim). Let `run()` accept a per-call `shell` override and pass `shell: false` for the `write-build-meta.mjs` invocation. This also fixes the spaced-repo-path case, since without a shell the args are passed verbatim. ## Environment - Windows 11 Pro (10.0.26200), Node.js in `C:\Program Files\nodejs` - Branch: `staging` (bug is not on `main` — `packages/server/scripts/build.mjs` only exists on staging) --- Taking this one myself — small fix PR against `staging` to follow shortly. (owner: @kolacheee)
bsakaguchi 2026-10-21 05:41:48 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1697
No description provided.