{"record":{"id":"3bafd948afe802d9","repo":"earendil-works/pi","slug":"command-failed-with-exit-code-result-status","errorCode":null,"errorMessage":"${command} failed with exit code ${result.status ?? 1}","messagePattern":"(.+?) failed with exit code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tui/native/win32/build.mjs","lineNumber":46,"sourceCode":"function removeTemporaryDir() {\n\trmSync(temporaryDir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n}\n\nprocess.on(\"exit\", removeTemporaryDir);\nprocess.on(\"SIGINT\", () => {\n\tremoveTemporaryDir();\n\tprocess.exit(130);\n});\n\nfunction commandExists(command) {\n\tconst result = spawnSync(command, [\"--version\"], { stdio: \"ignore\" });\n\treturn !result.error || result.error.code !== \"ENOENT\";\n}\n\nfunction run(command, args, options = {}) {\n\tconst result = spawnSync(command, args, { stdio: \"inherit\", ...options });\n\tif (result.error) throw result.error;\n\tif (result.status !== 0) throw new Error(`${command} failed with exit code ${result.status ?? 1}`);\n}\n\nfunction quoteBatch(value) {\n\treturn `\"${value.replaceAll('\"', '\"\"')}\"`;\n}\n\nfunction msvcHostArch() {\n\treturn process.arch === \"arm64\" ? \"arm64\" : \"x64\";\n}\n\nfunction findVisualStudioDevCmd() {\n\tconst candidates = [];\n\tconst programFilesX86 = process.env[\"ProgramFiles(x86)\"];\n\tif (programFilesX86) {\n\t\tconst vswhere = path.join(programFilesX86, \"Microsoft Visual Studio\", \"Installer\", \"vswhere.exe\");\n\t\tif (existsSync(vswhere)) {\n\t\t\tconst result = spawnSync(\n\t\t\t\tvswhere,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/tui/native/win32/build.mjs#L28-L64","documentation":"Build-script failure in the win32 native prebuild builder: an external command spawned by run() (compiler, rc.exe, cmd.exe batch, etc.) exited with a non-zero status (spawn errors are thrown separately as result.error). It means a toolchain step of the native module build failed; the thrown error carries the exit code for diagnosis, and the process exits before temporary artifacts are cleaned by the exit handler.","triggerScenarios":"Thrown at packages/tui/native/win32/build.mjs:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The build command failed; run it manually to see the full error output."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}