From b7f954a9041ee4524552ad0993e8b7711c86ff8a Mon Sep 17 00:00:00 2001 From: "(CJ) Chukwudi Nwobodo" <142016413+chuks-qua@users.noreply.github.com> Date: Mon, 9 Mar 2026 01:58:25 +0000 Subject: [PATCH] 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 --- apps/server/scripts/cli.ts | 2 ++ scripts/build-desktop-artifact.ts | 6 ++++++ scripts/dev-runner.ts | 2 ++ 3 files changed, 10 insertions(+) diff --git a/apps/server/scripts/cli.ts b/apps/server/scripts/cli.ts index e5b5c0d00ae0b82d178517643c16e7c8d10f2068..3eaa72ea8e73aaca17b745539c55933c8607c0d5 100644 --- a/apps/server/scripts/cli.ts +++ b/apps/server/scripts/cli.ts @@ -132,6 +132,7 @@ const buildCmd = Command.make( cwd: serverDir, stdout: config.verbose ? "inherit" : "ignore", stderr: "inherit", + // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd). shell: process.platform === "win32", })`bun tsdown`, ); @@ -226,6 +227,7 @@ const publishCmd = Command.make( cwd: serverDir, stdout: config.verbose ? "inherit" : "ignore", stderr: "inherit", + // Windows needs shell mode to resolve .cmd shims. shell: process.platform === "win32", }), ); diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts index 8823b88513446fcf22c28036caf249a371a3982c..c44109faea67d8e1370b8952899c7d3bf4ff51a9 100644 --- a/scripts/build-desktop-artifact.ts +++ b/scripts/build-desktop-artifact.ts @@ -580,6 +580,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* ( ChildProcess.make({ cwd: repoRoot, ...commandOutputOptions(options.verbose), + // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd). + shell: process.platform === "win32", })`bun run build:desktop`, ); } @@ -642,6 +644,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* ( ChildProcess.make({ cwd: stageAppDir, ...commandOutputOptions(options.verbose), + // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd). + shell: process.platform === "win32", })`bun install --production`, ); @@ -680,6 +684,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* ( cwd: stageAppDir, env: buildEnv, ...commandOutputOptions(options.verbose), + // Windows needs shell mode to resolve .cmd shims. + shell: process.platform === "win32", })`bunx electron-builder ${platformConfig.cliFlag} --${options.arch} --publish never`, ); diff --git a/scripts/dev-runner.ts b/scripts/dev-runner.ts index c72411e318bd8ddc807792548a68da4dfdd6bfc7..89d7a104cf7c2057f1e4984a00185610e8d1cdd6 100644 --- a/scripts/dev-runner.ts +++ b/scripts/dev-runner.ts @@ -455,6 +455,8 @@ export function runDevRunnerWithInput(input: DevRunnerCliInput) { stderr: "inherit", env, extendEnv: false, + // Windows needs shell mode to resolve .cmd shims (e.g. bun.cmd). + shell: process.platform === "win32", // Keep turbo in the same process group so terminal signals (Ctrl+C) // reach it directly. Effect defaults to detached: true on non-Windows, // which would put turbo in a new group and require manual forwarding. -- 2.54.0