{"record":{"id":"a9b9e69dfe6afeb4","repo":"stablyai/orca","slug":"bin-orca-target-is-not-a-file-bintarget","errorCode":null,"errorMessage":"bin.orca target is not a file: ${binTarget}","messagePattern":"bin\\.orca target is not a file: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/verify-cli-bin.mjs","lineNumber":38,"sourceCode":" * compiled output tree that the packaged CLI loads at runtime.\n */\nexport function verifyPackageCliBin({\n  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'))","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/verify-cli-bin.mjs#L20-L56","documentation":"After confirming bin.orca is a non-empty string, the verifier statSyncs the resolved target and requires it to be a regular file (stats.isFile()). This catches the case where the bin path resolves to a directory, a symlink-to-directory, or a special file — anything that would crash or misbehave when the OS exec()s it. Note ENOENT surfaces as a thrown statSync error, not this message.","triggerScenarios":"statSync(binPath).isFile() returns false at line 37. Happens when bin.orca points at a directory (e.g. `out/` instead of `out/cli/main.js`) or at a FIFO/socket/device.","commonSituations":"Pointing bin.orca at a folder by mistake during a build refactor; a stale path after the compiled layout changed; a symlink that resolves to a directory.","solutions":["Correct the bin.orca value in package.json to point at the actual compiled JS entry file.","If the path is correct but the file is missing, run the build that emits it (the ENOENT would normally surface from statSync first — verify the build ran).","Confirm no trailing slash or directory path leaked into the bin value."],"exampleFix":"// before\n\"bin\": { \"orca\": \"out/cli\" }\n// after\n\"bin\": { \"orca\": \"out/cli/main.js\" }","handlingStrategy":"validation","validationCode":"import { statSync } from 'node:fs'\nimport path from 'node:path'\nconst binPath = path.resolve(projectDir, pkg.bin.orca)\nconst st = statSync(binPath)\nif (!st.isFile()) throw new Error(`bin.orca target is not a regular file: ${binPath}`)","typeGuard":"import { statSync } from 'node:fs'\nfunction isRegularFile(p: string): boolean {\n  try { return statSync(p).isFile() } catch { return false }\n}","tryCatchPattern":null,"preventionTips":["Point bin.orca at the compiled JS file, not a directory.","Verify the path after any build-layout refactor."],"tags":["cli","packaging","filesystem","bin"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}