Skip to content

Commit a224af3

Browse files
committed
fix(build): pass environment to subprocess exec calls on Windows
Windows builds were failing with 'Could not locate Visual Studio installation' even though VS environment variables (VCINSTALLDIR, WindowsSDKVersion, INCLUDE, LIB) were successfully set via GITHUB_ENV and present in process.env. Root cause: The exec() helper from @socketsecurity/lib doesn't automatically inherit the parent process environment. Subprocesses (configure.py, ninja) were running without the VS environment variables. Fix: Explicitly pass 'env: process.env' to exec() calls for: - configure.py (line 1432) - ninja build (line 1505) This ensures VS environment variables are inherited by Python and ninja subprocesses, allowing them to locate Visual Studio. Debug logging added in 972b591 removed as issue is now identified and fixed.
1 parent 67a6938 commit a224af3

1 file changed

Lines changed: 2 additions & 26 deletions

File tree

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

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,32 +1428,8 @@ async function main() {
14281428
const configureCommand = WIN32 ? 'python' : './configure'
14291429
const configureArgs = WIN32 ? ['configure.py', ...configureFlags] : configureFlags
14301430

1431-
// DEBUG: Check if VS environment variables are present (Windows only).
1432-
if (WIN32) {
1433-
logger.log('')
1434-
logger.log('Verifying MSVC environment variables in build script:')
1435-
const criticalVars = ['VCINSTALLDIR', 'WindowsSDKVersion', 'INCLUDE', 'LIB']
1436-
let allPresent = true
1437-
for (const varName of criticalVars) {
1438-
const value = process.env[varName]
1439-
if (value) {
1440-
logger.log(` ${colors.green('✓')} ${varName} is set`)
1441-
} else {
1442-
logger.log(` ${colors.red('✗')} ${varName} is NOT SET`)
1443-
allPresent = false
1444-
}
1445-
}
1446-
if (!allPresent) {
1447-
logger.error('VS environment variables are missing!')
1448-
logger.log('configure.py will fail with "Could not locate Visual Studio installation"')
1449-
logger.log('This means GITHUB_ENV did not properly pass variables to this process.')
1450-
throw new Error('Missing VS environment variables')
1451-
}
1452-
logger.log('')
1453-
}
1454-
14551431
logger.log(`::group::Running ${WIN32 ? 'python configure.py' : './configure'}`)
1456-
await exec(configureCommand, configureArgs, { cwd: NODE_DIR })
1432+
await exec(configureCommand, configureArgs, { cwd: NODE_DIR, env: process.env })
14571433
logger.log('::endgroup::')
14581434
logger.log(`${colors.green('✓')} Configuration complete`)
14591435
logger.log('')
@@ -1502,7 +1478,7 @@ async function main() {
15021478
logger.log('::group::Compiling Node.js with Ninja (this will take a while...)')
15031479

15041480
try {
1505-
await exec('ninja', ['-C', 'out/Release', `-j${CPU_COUNT}`], { cwd: NODE_DIR })
1481+
await exec('ninja', ['-C', 'out/Release', `-j${CPU_COUNT}`], { cwd: NODE_DIR, env: process.env })
15061482
logger.log('::endgroup::')
15071483
} catch (e) {
15081484
logger.log('::endgroup::')

0 commit comments

Comments
 (0)