{"record":{"id":"dcc79e0e5d90824c","repo":"stablyai/orca","slug":"bin-orca-target-is-empty-bintarget","errorCode":null,"errorMessage":"bin.orca target is empty: ${binTarget}","messagePattern":"bin\\.orca target is empty: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/verify-cli-bin.mjs","lineNumber":41,"sourceCode":"  projectDir = path.resolve(import.meta.dirname, '..', '..'),\n  fixExecutable = false,\n  fixPackageJson = false,\n  runHelp = false\n} = {}) {\n  const packageJsonPath = path.join(projectDir, 'package.json')\n  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'))\n  const binTarget = packageJson.bin?.orca\n  if (typeof binTarget !== 'string' || binTarget.length === 0) {\n    throw new Error('package.json must declare bin.orca')\n  }\n\n  const binPath = path.resolve(projectDir, binTarget)\n  const stats = statSync(binPath)\n  if (!stats.isFile()) {\n    throw new Error(`bin.orca target is not a file: ${binTarget}`)\n  }\n  if (stats.size === 0) {\n    throw new Error(`bin.orca target is empty: ${binTarget}`)\n  }\n\n  const content = readFileSync(binPath, 'utf8')\n  if (!content.startsWith('#!/usr/bin/env node\\n')) {\n    throw new Error(`bin.orca target must start with a Node shebang: ${binTarget}`)\n  }\n\n  const outPackageJsonPath = path.join(projectDir, 'out', 'package.json')\n  if (fixPackageJson) {\n    mkdirSync(path.dirname(outPackageJsonPath), { recursive: true })\n    writeFileSync(outPackageJsonPath, OUT_COMMONJS_PACKAGE_JSON, 'utf8')\n  }\n  let outPackageJson\n  try {\n    outPackageJson = JSON.parse(readFileSync(outPackageJsonPath, 'utf8'))\n  } catch (error) {\n    if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {\n      throw new Error(","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/verify-cli-bin.mjs#L23-L59","documentation":"The bin target exists and is a regular file but has zero bytes — a build that emitted an empty placeholder, a truncated write, or a stub. An empty executable would either fail with an exec format error or, worse, be skipped silently by some launchers, so the gate rejects it explicitly. The interpolated binTarget names the offending path.","triggerScenarios":"statSync(binPath).size === 0 at line 40. Caused by a build step that created the file but wrote nothing (failed transpilation that still touched the path), a `touch` placeholder, or a partial write interrupted mid-build.","commonSituations":"A broken bundler config that opens the output file but errors before writing content; a watch-mode race where the file is stat'd during a rebuild; a corrupted checkout after an interrupted build.","solutions":["Rebuild the CLI bundle (`pnpm run build:electron-vite` or the dedicated CLI build) and confirm the entry is non-empty.","Delete the empty file and rebuild to rule out a stale-touch race.","If the build genuinely produces an empty file, fix the bundler entry/config before re-running verify-cli-bin."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const st = statSync(binPath)\nif (st.size === 0) throw new Error(`refusing to verify empty bin target: ${binPath}`)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat an empty built entry as a build failure; investigate the bundler.","Rebuild from clean (rm -rf out/) to rule out a stale-touch race."],"tags":["cli","packaging","build","bin"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}