authorgravatar for 142016413+chuks-qua@users.noreply.github.com(CJ) Chukwudi Nwobodo <142016413+chuks-qua@users.noreply.github.com> 2026-03-09 01:58:25+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-03-08 18:58:25-07:00
logb7f954a9041ee4524552ad0993e8b7711c86ff8a
tree413ab878a799ca8d54867e68c02f178ebbd428c8
parenta20815ece6ea877a2b82072339f4bced98d757f7
signature Signed by PGP key B5690EEEBB952194

Fix ChildProcess.spawn failing on Windows for .cmd shims (#495)

* fix(scripts): enable shell mode on Windows for .cmd shim resolution On Windows, tools like `bun`, `npm`, `turbo`, and `bunx` are installed as `.cmd` shims. Node's `child_process.spawn` cannot resolve these without `shell: true`, causing `PlatformError: NotFound` on fresh builds where there is no Turbo cache. Add `shell: process.platform === "win32"` to all ChildProcess.make calls in cli.ts, dev-runner.ts, and build-desktop-artifact.ts. Closes #474 * docs: add comments explaining Windows shell spawn requirement * docs: add shell spawn comments to remaining call sites

3 files changed, 10 insertions(+), 0 deletions(-)

apps/server/scripts/cli.ts+2
...@@ -132,6 +132,7 @@ const buildCmd = Command.make(...@@ -132,6 +132,7 @@ const buildCmd = Command.make(
132 cwd: serverDir,132 cwd: serverDir,
133 stdout: config.verbose ? "inherit" : "ignore",133 stdout: config.verbose ? "inherit" : "ignore",
134 stderr: "inherit",134 stderr: "inherit",
135 // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
135 shell: process.platform === "win32",136 shell: process.platform === "win32",
136 })`bun tsdown`,137 })`bun tsdown`,
137 );138 );
...@@ -226,6 +227,7 @@ const publishCmd = Command.make(...@@ -226,6 +227,7 @@ const publishCmd = Command.make(
226 cwd: serverDir,227 cwd: serverDir,
227 stdout: config.verbose ? "inherit" : "ignore",228 stdout: config.verbose ? "inherit" : "ignore",
228 stderr: "inherit",229 stderr: "inherit",
230 // Windows needs shell mode to resolve .cmd shims.
229 shell: process.platform === "win32",231 shell: process.platform === "win32",
230 }),232 }),
231 );233 );
scripts/build-desktop-artifact.ts+6
...@@ -580,6 +580,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -580,6 +580,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
580 ChildProcess.make({580 ChildProcess.make({
581 cwd: repoRoot,581 cwd: repoRoot,
582 ...commandOutputOptions(options.verbose),582 ...commandOutputOptions(options.verbose),
583 // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
584 shell: process.platform === "win32",
583 })`bun run build:desktop`,585 })`bun run build:desktop`,
584 );586 );
585 }587 }
...@@ -642,6 +644,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -642,6 +644,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
642 ChildProcess.make({644 ChildProcess.make({
643 cwd: stageAppDir,645 cwd: stageAppDir,
644 ...commandOutputOptions(options.verbose),646 ...commandOutputOptions(options.verbose),
647 // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
648 shell: process.platform === "win32",
645 })`bun install --production`,649 })`bun install --production`,
646 );650 );
647651
...@@ -680,6 +684,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (...@@ -680,6 +684,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
680 cwd: stageAppDir,684 cwd: stageAppDir,
681 env: buildEnv,685 env: buildEnv,
682 ...commandOutputOptions(options.verbose),686 ...commandOutputOptions(options.verbose),
687 // Windows needs shell mode to resolve .cmd shims.
688 shell: process.platform === "win32",
683 })`bunx electron-builder ${platformConfig.cliFlag} --${options.arch} --publish never`,689 })`bunx electron-builder ${platformConfig.cliFlag} --${options.arch} --publish never`,
684 );690 );
685691
scripts/dev-runner.ts+2
...@@ -455,6 +455,8 @@ export function runDevRunnerWithInput(input: DevRunnerCliInput) {...@@ -455,6 +455,8 @@ export function runDevRunnerWithInput(input: DevRunnerCliInput) {
455 stderr: "inherit",455 stderr: "inherit",
456 env,456 env,
457 extendEnv: false,457 extendEnv: false,
458 // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd).
459 shell: process.platform === "win32",
458 // Keep turbo in the same process group so terminal signals (Ctrl+C)460 // Keep turbo in the same process group so terminal signals (Ctrl+C)
459 // reach it directly. Effect defaults to detached: true on non-Windows,461 // reach it directly. Effect defaults to detached: true on non-Windows,
460 // which would put turbo in a new group and require manual forwarding.462 // which would put turbo in a new group and require manual forwarding.