Skip to content

Commit bfc8fae

Browse files
committed
fix(smol): set GYP_MSVS_VERSION to bypass VS auto-detection
Gyp's auto-detection fails even with VS environment variables set. Setting GYP_MSVS_VERSION=2022 tells gyp to use VS 2022 directly.
1 parent d9a26cc commit bfc8fae

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,11 +1452,20 @@ async function main() {
14521452
// propagate environment variables to subprocesses.
14531453
const execOptions = {
14541454
cwd: NODE_DIR,
1455-
env: process.env,
1455+
env: WIN32
1456+
? {
1457+
...process.env,
1458+
// Tell gyp to use VS 2022, bypassing auto-detection.
1459+
// https://github.com/nodejs/node/blob/main/BUILDING.md#windows
1460+
// https://github.com/nodejs/node/blob/main/tools/gyp/pylib/gyp/MSVSVersion.py
1461+
GYP_MSVS_VERSION: '2022',
1462+
}
1463+
: process.env,
14561464
shell: false,
14571465
}
14581466
if (WIN32) {
1459-
logger.log(`DEBUG: Passing env with ${Object.keys(process.env).length} variables (shell: false)`)
1467+
logger.log(`DEBUG: Passing env with ${Object.keys(execOptions.env).length} variables (shell: false)`)
1468+
logger.log(`DEBUG: GYP_MSVS_VERSION = ${execOptions.env.GYP_MSVS_VERSION}`)
14601469
}
14611470

14621471
await exec(configureCommand, configureArgs, execOptions)

0 commit comments

Comments
 (0)