stablyai/orca · error · Error

node-pty resolved to ${native.dir}; expected build/Release s

Error message

node-pty resolved to ${native.dir}; expected build/Release so Orca's node-pty patch is active

What it means

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.

Source

Thrown at config/scripts/rebuild-native-deps.mjs:480

if (failures.length > 0) {
  console.error(failures.join('\\n'))
  process.exit(1)
}

function loadNativeModule(moduleName) {
  if (moduleName === 'windows-native-registry') {
    const registry = projectRequire(moduleName)
    // Why: the package defers loading its .node addon until the first registry call.
    registry.getRegistryKey(registry.HK.CU, 'Environment')
    return
  }
  if (moduleName === 'node-pty') {
    projectRequire('node-pty')
    const { loadNativeModule } = projectRequire('node-pty/lib/utils')
    const native = loadNativeModule(getNodePtyNativeModuleName())
    assertNodePtyWindowsConptyRuntime(native.dir)
    if (requirePatchedNodePtySourceBuild && !isNodePtyReleaseBuildDir(native.dir)) {
      throw new Error(
        'node-pty resolved to ' +
          native.dir +
          '; expected build/Release so Orca\\'s node-pty patch is active'
      )
    }
    return
  }
  projectRequire(moduleName)
}

function assertNodePtyWindowsConptyRuntime(nativeDir) {
  if (process.platform !== 'win32' || !isNodePtyReleaseBuildDir(nativeDir)) {
    return
  }
  const runtimeDir = resolve(
    process.cwd(),
    'node_modules',
    'node-pty',

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Rerun rebuild-native-deps.mjs (or ensure-native-runtime.mjs --runtime=electron) so the patched source build runs and writes build/Release/pty.node.
  2. 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.
  3. Remove cached prebuilds (node_modules/node-pty/prebuilds) before rebuilding so the patched source path is the only one available.

Example fix

// before
# prebuilt pty.node loaded; patched build missing
node config/scripts/rebuild-native-deps.mjs --only node-pty
# -> node-pty resolved to .../prebuilds/...; expected build/Release

// after
rm -rf node_modules/node-pty/prebuilds
node config/scripts/rebuild-native-deps.mjs --only node-pty
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'node:fs'
import { resolve } from 'node:path'

const releasePty = resolve('node_modules', 'node-pty', 'build', 'Release', 'pty.node')
const prebuildsDir = resolve('node_modules', 'node-pty', 'prebuilds')
if (!existsSync(releasePty) && existsSync(prebuildsDir)) {
  throw new Error('Patched node-pty build missing; remove prebuilds and rerun rebuild-native-deps.mjs')
}

Type guard

function isNodePtyReleaseBuildDir(nativeDir) {
  return typeof nativeDir === 'string' && nativeDir.replace(/\\/g, '/').includes('build/Release/')
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/ff86395480001674. Report an issue: GitHub.