{"record":{"id":"57dd9c3744b0d649","repo":"FuelLabs/fuels-ts","slug":"bin-file-not-found","errorCode":"BIN_FILE_NOT_FOUND","errorMessage":"Could not find BIN file for counterpart ${upperFirst(programType)} ABI.\\n  - ABI: ${abiFilepath}\\n  - BIN: ${binFilepath}\\n${programType}","messagePattern":"Could not find BIN file for counterpart (.+?) ABI\\.\\\\n  - ABI: (.+?)\\\\n  - BIN: (.+?)\\\\n(.+?)","errorType":"exception","errorClass":"FuelError","httpStatus":null,"severity":"error","filePath":"packages/abi-typegen/src/utils/validateBinFile.ts","lineNumber":18,"sourceCode":"import { ErrorCode, FuelError } from '@fuel-ts/errors';\n\nimport { ProgramTypeEnum } from '../types/enums/ProgramTypeEnum';\n\nconst upperFirst = (s: string): string => s[0].toUpperCase() + s.slice(1);\n\nexport function validateBinFile(params: {\n  abiFilepath: string;\n  binFilepath: string;\n  binExists: boolean;\n  programType: ProgramTypeEnum;\n}) {\n  const { abiFilepath, binFilepath, binExists, programType } = params;\n\n  const isScript = programType === ProgramTypeEnum.SCRIPT;\n\n  if (!binExists && isScript) {\n    throw new FuelError(\n      ErrorCode.BIN_FILE_NOT_FOUND,\n      [\n        `Could not find BIN file for counterpart ${upperFirst(programType)} ABI.`,\n        `  - ABI: ${abiFilepath}`,\n        `  - BIN: ${binFilepath}`,\n        programType,\n      ].join('\\n')\n    );\n  }\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/FuelLabs/fuels-ts/blob/b3f37c91aca4aa9d5e4c0d3967f66237190826ea/packages/abi-typegen/src/utils/validateBinFile.ts#L1-L29","documentation":"validateBinFile throws only when programType is SCRIPT and the corresponding BIN file does not exist on disk. A Sway script requires its compiled .bin artifact (compiled bytecode) to be embedded in the generated wrapper; without it the wrapper cannot be deployed/executed. ABI alone is insufficient for scripts.","triggerScenarios":"Running typegen for a script where the .bin counterpart of the ABI is missing (different filename, not built, deleted); ABI and BIN naming mismatch so the bin-existence check returns false.","commonSituations":"Forgetting to run `forc build` before typegen; .bin file named differently from the ABI; CI that ships the ABI but not the BIN; cleaning build artifacts between build and typegen steps.","solutions":["Build the script first: `forc build` to produce the .bin next to the -abi.json.","Ensure the .bin filename matches the ABI basename (same stem, .bin suffix).","Point typegen's filepaths/globs at the directory that contains both the ABI and the BIN."],"exampleFix":"# before\nforc build --path ./script        # skipped or failed\nfuels typegen -i ./script/out/MyScript-abi.json -t script ...\n\n# after\nforc build --path ./script\nfuels typegen -i ./script/out/*-abi.json -t script ...","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nimport { ProgramTypeEnum } from '@fuel-ts/abi-typegen';\nfunction assertBinExists(abiFilepath: string, binFilepath: string, programType: ProgramTypeEnum) {\n  if (programType === ProgramTypeEnum.SCRIPT && !existsSync(binFilepath)) {\n    throw new Error(`Missing BIN for script ABI ${abiFilepath}: expected ${binFilepath}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `forc build` before typegen so the .bin artifact exists.","Keep ABI and BIN filename stems aligned in the same output directory.","Do not clean build artifacts between build and typegen steps in CI."],"tags":["typegen","bin-file-not-found","script","build","filesystem"],"backgroundTag":null,"analyzedSha":"b3f37c91aca4aa9d5e4c0d3967f66237190826ea","analyzedAt":"2026-08-12T20:30:56.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}