Skip to content

Commit df1b763

Browse files
committed
fix(build): disable shell wrapper when passing custom environment
Root cause: When exec() uses shell: true (WIN32), the spawn helper wraps commands in cmd.exe. Environment variables passed via env option are not properly propagated from cmd.exe to subprocesses (python, ninja). Debug output confirmed: - ✅ VS variables exist in process.env - ✅ env option passed with 221 variables - ❌ configure.py subprocess can't see variables Solution: Set shell: false when passing custom env on Windows. This calls python/ninja directly without cmd.exe wrapper, ensuring environment variables are inherited correctly. Applied to: - configure.py execution (line 1455) - ninja build execution (line 1511) This is the correct fix for the Windows smol build failure.
1 parent 8352944 commit df1b763

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

packages/node-smol-builder/scripts/build.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,10 +1447,13 @@ async function main() {
14471447
logger.log(`::group::Running ${WIN32 ? 'python configure.py' : './configure'}`)
14481448

14491449
// On Windows, explicitly pass environment to subprocess.
1450+
// IMPORTANT: When passing custom env, we must disable shell wrapping (shell: false)
1451+
// because cmd.exe doesn't properly propagate environment variables to subprocesses.
14501452
const execOptions = { cwd: NODE_DIR }
14511453
if (WIN32) {
14521454
execOptions.env = process.env
1453-
logger.log(`DEBUG: Passing env option with ${Object.keys(process.env).length} variables`)
1455+
execOptions.shell = false // Critical: disable cmd.exe wrapper
1456+
logger.log(`DEBUG: Passing env with ${Object.keys(process.env).length} variables (shell: false)`)
14541457
}
14551458

14561459
await exec(configureCommand, configureArgs, execOptions)
@@ -1502,7 +1505,12 @@ async function main() {
15021505
logger.log('::group::Compiling Node.js with Ninja (this will take a while...)')
15031506

15041507
try {
1505-
await exec('ninja', ['-C', 'out/Release', `-j${CPU_COUNT}`], { cwd: NODE_DIR, env: process.env })
1508+
// On Windows, disable shell wrapper when passing env (same as configure.py).
1509+
const ninjaOptions = { cwd: NODE_DIR, env: process.env }
1510+
if (WIN32) {
1511+
ninjaOptions.shell = false
1512+
}
1513+
await exec('ninja', ['-C', 'out/Release', `-j${CPU_COUNT}`], ninjaOptions)
15061514
logger.log('::endgroup::')
15071515
} catch (e) {
15081516
logger.log('::endgroup::')

0 commit comments

Comments
 (0)