{"record":{"id":"661283bb90d6a8e6","repo":"oven-sh/bun","slug":"cmake-build-root-is-not-defined","errorCode":null,"errorMessage":"CMAKE_BUILD_ROOT is not defined","messagePattern":"CMAKE_BUILD_ROOT is not defined","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bundle-functions.ts","lineNumber":63,"sourceCode":"import assert from \"assert\";\nimport { readdirSync, rmSync } from \"fs\";\nimport path from \"path\";\nimport { sliceSourceCode } from \"./builtin-parser\";\nimport { createAssertClientJS, createLogClientJS } from \"./client-js\";\nimport { getJS2NativeDTS } from \"./generate-js2native\";\nimport { cap, checkAscii, low, writeIfNotChanged } from \"./helpers\";\nimport { applyGlobalReplacements, define } from \"./replacements\";\n\nconst PARALLEL = false;\nconst KEEP_TMP = true;\n\nif (import.meta.main) {\n  throw new Error(\"This script is not meant to be run directly\");\n}\n\nconst CMAKE_BUILD_ROOT = globalThis.CMAKE_BUILD_ROOT;\nif (!CMAKE_BUILD_ROOT) {\n  throw new Error(\"CMAKE_BUILD_ROOT is not defined\");\n}\n\nconst SRC_DIR = path.join(import.meta.dir, \"../js/builtins\");\nconst CODEGEN_DIR = path.join(CMAKE_BUILD_ROOT, \"./codegen\");\nconst TMP_DIR = path.join(CMAKE_BUILD_ROOT, \"./tmp_functions\");\n\ninterface ParsedBuiltin {\n  name: string;\n  params: string[];\n  directives: Record<string, any>;\n  source: string;\n  async: boolean;\n  enums: string[];\n}\n\ninterface BundledBuiltin {\n  name: string;\n  directives: Record<string, any>;","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bundle-functions.ts#L45-L81","documentation":"Guard in bundle-functions.ts: the expected global CMAKE_BUILD_ROOT was not defined by the calling build script. All output paths in this generator are derived from it, so continuing would write generated files to `undefined`-containing paths. It indicates the module was loaded outside the cmake-driven codegen context.","triggerScenarios":"Thrown at src/codegen/bundle-functions.ts:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the generator via the build scripts that set globalThis.CMAKE_BUILD_ROOT before importing this module","Set globalThis.CMAKE_BUILD_ROOT to the build directory explicitly in a custom harness before import"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","contentChangedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}