{"record":{"id":"ff86395480001674","repo":"stablyai/orca","slug":"node-pty-resolved-to-native-dir-expected-build","errorCode":null,"errorMessage":"node-pty resolved to ${native.dir}; expected build/Release so Orca's node-pty patch is active","messagePattern":"node-pty resolved to (.+?); expected build/Release so Orca's node-pty patch is active","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"config/scripts/rebuild-native-deps.mjs","lineNumber":480,"sourceCode":"if (failures.length > 0) {\n  console.error(failures.join('\\\\n'))\n  process.exit(1)\n}\n\nfunction loadNativeModule(moduleName) {\n  if (moduleName === 'windows-native-registry') {\n    const registry = projectRequire(moduleName)\n    // Why: the package defers loading its .node addon until the first registry call.\n    registry.getRegistryKey(registry.HK.CU, 'Environment')\n    return\n  }\n  if (moduleName === 'node-pty') {\n    projectRequire('node-pty')\n    const { loadNativeModule } = projectRequire('node-pty/lib/utils')\n    const native = loadNativeModule(getNodePtyNativeModuleName())\n    assertNodePtyWindowsConptyRuntime(native.dir)\n    if (requirePatchedNodePtySourceBuild && !isNodePtyReleaseBuildDir(native.dir)) {\n      throw new Error(\n        'node-pty resolved to ' +\n          native.dir +\n          '; expected build/Release so Orca\\\\'s node-pty patch is active'\n      )\n    }\n    return\n  }\n  projectRequire(moduleName)\n}\n\nfunction assertNodePtyWindowsConptyRuntime(nativeDir) {\n  if (process.platform !== 'win32' || !isNodePtyReleaseBuildDir(nativeDir)) {\n    return\n  }\n  const runtimeDir = resolve(\n    process.cwd(),\n    'node_modules',\n    'node-pty',","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/rebuild-native-deps.mjs#L462-L498","documentation":"Thrown by the Electron native-module probe (probeElectronNativeModules) in config/scripts/rebuild-native-deps.mjs when Orca requires a patched node-pty source build (requirePatchedNodePtySourceBuild is true — config/patches/node-pty@1.1.0.patch exists and node-pty is in the only-modules set on a non-win32 native platform) but the resolved native module directory is not under `build/Release`. That means a prebuilt/upstream binary loaded instead of the patched source build, so Orca's spawn fd/error-handling patch is not active.","triggerScenarios":"Run rebuild-native-deps.mjs's probe on macOS/Linux with node-pty in scope, the patch file present, but a prebuilt pty.node resolving from prebuild-install or a stale non-build/Release location. loadNativeModule resolves native.dir, isNodePtyReleaseBuildDir returns false, and the probe throws at lines 479-484.","commonSituations":"The patched source rebuild step was skipped or failed silently (leaving prebuilds in place), a prior install cached an upstream prebuild, or the patch failed to apply on a node-pty version bump. The check exists precisely because upstream prebuilds load successfully in Electron while missing Orca's fd/error fixes.","solutions":["Rerun rebuild-native-deps.mjs (or ensure-native-runtime.mjs --runtime=electron) so the patched source build runs and writes build/Release/pty.node.","Confirm config/patches/node-pty@1.1.0.patch still applies against the installed node-pty version; bump/refresh the patch if node-pty was upgraded.","Remove cached prebuilds (node_modules/node-pty/prebuilds) before rebuilding so the patched source path is the only one available."],"exampleFix":"// before\n# prebuilt pty.node loaded; patched build missing\nnode config/scripts/rebuild-native-deps.mjs --only node-pty\n# -> node-pty resolved to .../prebuilds/...; expected build/Release\n\n// after\nrm -rf node_modules/node-pty/prebuilds\nnode config/scripts/rebuild-native-deps.mjs --only node-pty","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nconst releasePty = resolve('node_modules', 'node-pty', 'build', 'Release', 'pty.node')\nconst prebuildsDir = resolve('node_modules', 'node-pty', 'prebuilds')\nif (!existsSync(releasePty) && existsSync(prebuildsDir)) {\n  throw new Error('Patched node-pty build missing; remove prebuilds and rerun rebuild-native-deps.mjs')\n}","typeGuard":"function isNodePtyReleaseBuildDir(nativeDir) {\n  return typeof nativeDir === 'string' && nativeDir.replace(/\\\\/g, '/').includes('build/Release/')\n}","tryCatchPattern":null,"preventionTips":["Run rebuild-native-deps.mjs (or ensure-native-runtime.mjs --runtime=electron) to produce the patched build/Release artifacts.","Remove node_modules/node-pty/prebuilds before rebuilding so upstream prebuilds cannot load.","Keep config/patches/node-pty@1.1.0.patch applicable when bumping node-pty."],"tags":["native","node-pty","electron","build","patch","rebuild"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}