stablyai/orca · critical
Packaged main file ${file} was not found in ${asarPath}
Error message
Packaged main file ${file} was not found in ${asarPath} What it means
The `verifyPackagedMainRuntimeDeps` function opens the packaged app.asar archive and looks for specific main bundle files ('out/main/index.js' and 'out/main/agent-hooks/managed-agent-hook-controls.js'). If either is not found in the asar entry list, this error fires. This is a layout contract check — it verifies the asar contains the expected entry points before scanning them for bare require() calls.
Source
Thrown at config/packaged-runtime-node-modules.cjs:228
function findAsarEntry(entries, expectedPath) {
return entries.find((entry) => normalizeAsarEntryPath(entry) === expectedPath)
}
function verifyPackagedMainRuntimeDeps(resourcesDir, asar = require('@electron/asar')) {
const asarPath = join(resourcesDir, 'app.asar')
if (!existsSync(asarPath)) {
return
}
const mainFiles = ['out/main/index.js', 'out/main/agent-hooks/managed-agent-hook-controls.js']
const entries = asar.listPackage(asarPath)
const missing = new Set()
for (const file of mainFiles) {
const entry = findAsarEntry(entries, file)
if (!entry) {
throw new Error(`Packaged main file ${file} was not found in ${asarPath}`)
}
// Why: @electron/asar lists entries with host separators; Windows returns
// backslashes, and extractFile expects that same host-style path.
const internalPath = entry.replace(/^[\\/]+/, '')
const source = asar.extractFile(asarPath, internalPath).toString('utf8')
for (const match of source.matchAll(/require\(["']([^"']+)["']\)/g)) {
const specifier = match[1]
if (!isPackagedExternalSpecifier(specifier)) {
continue
}
const packageName = packageNameFromSpecifier(specifier)
if (!existsSync(join(resourcesDir, 'node_modules', ...packageName.split('/')))) {
missing.add(packageName)
}
}
}
View on GitHub (pinned to 1136503c6a)
Solutions
- Check the `mainFiles` array at packaged-runtime-node-modules.cjs:221 — if you renamed the rollup input for the main entry or agent-hooks entry, update the paths here.
- Inspect the actual asar contents: `npx @electron/asar list path/to/app.asar | grep 'out/main/'` to see what paths are actually present.
- Check the `files` filter in electron-builder.config.cjs — ensure none of the exclusion patterns accidentally match the main bundle output.
- Verify the rollup output config (`entryFileNames: '[name].js'`) hasn't changed to add a hash or prefix.
Example fix
// before — rollup input renamed from 'index' to 'main-index'
// electron.vite.config.ts
input: { 'main-index': resolve('src/main/index.ts') }
// after — update mainFiles in packaged-runtime-node-modules.cjs
const mainFiles = ['out/main/main-index.js', 'out/main/agent-hooks/managed-agent-hook-controls.js'] Defensive patterns
Strategy: validation
Validate before calling
// Verify expected main files exist in the asar before scanning
import asar from '@electron/asar'
function verifyMainFilesInAsar(asarPath, expectedFiles) {
const entries = asar.listPackage(asarPath)
const missing = expectedFiles.filter(f =>
!entries.some(e => e.replace(/\\/g, '/').replace(/^\/+/, '') === f)
)
if (missing.length) throw new Error(`Missing in asar: ${missing.join(', ')}`)
} Prevention
- When renaming a rollup input key for the main entry or agent-hooks, update the mainFiles list at packaged-runtime-node-modules.cjs:221.
- Run `npx @electron/asar list app.asar` to inspect packaged contents after build changes.
- Keep the output config `entryFileNames: '[name].js'` stable — hashing or prefixes will break the path check.
When it happens
Trigger: The main bundle entry was renamed in the rollup config (electron.vite.config.ts input keys) without updating the `mainFiles` list at line 221. The build produced output to a different directory structure (e.g., 'out/main/' became 'out/electron-main/'). The asar packaging excluded these files via the `files` filter in electron-builder config. A build step that moves or renames output files after rollup but before asar packing.
Common situations: Renaming the rollup input key for index.js or managed-agent-hook-controls. Changing the output directory structure in the vite/rollup config. The `files` exclusion patterns in electron-builder.config.cjs accidentally filtering out these paths. A vite plugin that changes output file naming.
Related errors
- Packaged main bundle has bare runtime imports without copied
- codex trust-grant entry bundle not found
- [plain-node-entry-guard] guarded ${missing.map((name) => `"$
- [plain-node-entry-guard] "${entryName}" reaches chunk "${chu
- Missing packaged resources directory: ${resourcesDir}
AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12).
Data as JSON: /api/errors/fa6f892d7cefbc30.
Report an issue: GitHub.