FuelLabs/fuels-ts · error · FuelError
BIN_FILE_NOT_FOUND
BIN_FILE_NOT_FOUND
Error message
Could not find BIN file for counterpart ${upperFirst(programType)} ABI.\n - ABI: ${abiFilepath}\n - BIN: ${binFilepath}\n${programType} What it means
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.
Source
Thrown at packages/abi-typegen/src/utils/validateBinFile.ts:18
import { ErrorCode, FuelError } from '@fuel-ts/errors';
import { ProgramTypeEnum } from '../types/enums/ProgramTypeEnum';
const upperFirst = (s: string): string => s[0].toUpperCase() + s.slice(1);
export function validateBinFile(params: {
abiFilepath: string;
binFilepath: string;
binExists: boolean;
programType: ProgramTypeEnum;
}) {
const { abiFilepath, binFilepath, binExists, programType } = params;
const isScript = programType === ProgramTypeEnum.SCRIPT;
if (!binExists && isScript) {
throw new FuelError(
ErrorCode.BIN_FILE_NOT_FOUND,
[
`Could not find BIN file for counterpart ${upperFirst(programType)} ABI.`,
` - ABI: ${abiFilepath}`,
` - BIN: ${binFilepath}`,
programType,
].join('\n')
);
}
}
View on GitHub (pinned to b3f37c91ac)
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.
Example fix
# before forc build --path ./script # skipped or failed fuels typegen -i ./script/out/MyScript-abi.json -t script ... # after forc build --path ./script fuels typegen -i ./script/out/*-abi.json -t script ...
Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'node:fs';
import { ProgramTypeEnum } from '@fuel-ts/abi-typegen';
function assertBinExists(abiFilepath: string, binFilepath: string, programType: ProgramTypeEnum) {
if (programType === ProgramTypeEnum.SCRIPT && !existsSync(binFilepath)) {
throw new Error(`Missing BIN for script ABI ${abiFilepath}: expected ${binFilepath}`);
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of FuelLabs/fuels-ts@b3f37c91ac (2026-08-12).
Data as JSON: /api/errors/57dd9c3744b0d649.
Report an issue: GitHub.