stablyai/orca · error · Error

node-pty is missing ${sourceFile}

Error message

node-pty is missing ${sourceFile}

What it means

Thrown by the ConPTY-restore step in config/scripts/rebuild-native-deps.mjs when the per-arch source payload directory was found, but one of the files in NODE_PTY_CONPTY_RUNTIME_FILES (the expected ConPTY DLL set) is absent inside it. This means node-pty's bundled payload is incomplete — the directory exists but is missing a required DLL, so copying the runtime set cannot complete.

Source

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

  const nodePtyDir = resolve(projectDir, 'node_modules', 'node-pty')
  if (!existsSync(join(nodePtyDir, 'build', 'Release', 'conpty.node'))) {
    return
  }
  const conptyRoot = join(nodePtyDir, 'third_party', 'conpty')
  const sourceDir = readdirSync(conptyRoot, { withFileTypes: true })
    .filter((entry) => entry.isDirectory())
    .map((entry) => join(conptyRoot, entry.name, `win10-${rebuildArch}`))
    .find((candidate) => existsSync(candidate))
  if (!sourceDir) {
    throw new Error(`node-pty has no ConPTY runtime payload for win10-${rebuildArch}`)
  }

  const runtimeDir = join(nodePtyDir, 'build', 'Release', 'conpty')
  mkdirSync(runtimeDir, { recursive: true })
  for (const filename of NODE_PTY_CONPTY_RUNTIME_FILES) {
    const sourceFile = join(sourceDir, filename)
    if (!existsSync(sourceFile)) {
      throw new Error(`node-pty is missing ${sourceFile}`)
    }
    copyFileSync(sourceFile, join(runtimeDir, filename))
  }
  // Why: @electron/rebuild bypasses node-pty's postinstall step that normally copies these DLLs.
  console.log(`[rebuild] Restored node-pty ConPTY runtime files for win10-${rebuildArch}.`)
}

function ensureElectronPackageInstalled() {
  if (electronPackageIsUsable()) {
    return
  }

  // Why: CI has observed Electron's postinstall exiting cleanly without
  // writing path.txt. Electron 42's lazy require() would run install.js here,
  // so inspect dist/ directly and keep using our strict partial-extract checks.
  console.log('[rebuild] Electron package binary is missing; installing Electron package binary.')
  resetPartialElectronInstall()
  try {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Fully reinstall node-pty to repopulate the entire win10-<arch> payload directory.
  2. Clear the npm/pnpm cache (`npm cache clean --force`) before reinstalling if corruption is suspected.
  3. Check antivirus/quarantine logs if a specific DLL keeps disappearing after restore.

Example fix

// before
# node-pty/third_party/conpty/<ver>/win10-x64 exists but is missing conpty.dll
node config/scripts/rebuild-native-deps.mjs --platform win32

// after
rm -rf node_modules/node-pty && npm install
node config/scripts/rebuild-native-deps.mjs --platform win32
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync, readdirSync } from 'node:fs'
import { join } from 'node:path'

const conptyRoot = join('node_modules', 'node-pty', 'third_party', 'conpty')
const arch = process.env.npm_config_arch || process.arch
const sourceDir = readdirSync(conptyRoot, { withFileTypes: true })
  .filter((e) => e.isDirectory())
  .map((e) => join(conptyRoot, e.name, `win10-${arch}`))
  .find(existsSync)
// Verify every expected DLL is present before rebuilding
const expected = ['conpty.dll'] // subset of NODE_PTY_CONPTY_RUNTIME_FILES
const missing = expected.filter((f) => !existsSync(join(sourceDir, f)))
if (missing.length) throw new Error(`Incomplete ConPTY payload, missing: ${missing.join(', ')}`)

Prevention

When it happens

Trigger: On Windows, after rebuild, the sourceDir `win10-<arch>` exists but is missing one of the entries in NODE_PTY_CONPTY_RUNTIME_FILES (e.g. conpty.dll was deleted, or a partial extract left only some files). The loop at lines 188-192 throws on the first missing sourceFile.

Common situations: A previous interrupted npm install or cache corruption left the ConPTY payload half-populated; an antivirus quarantined one of the Microsoft ConPTY DLLs; or a node-pty version change altered the expected file list while an old payload dir lingered.

Related errors


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