{"record":{"id":"2ccc6e8c0031d81b","repo":"FuelLabs/fuels-rs","slug":"abigen-generation-failed","errorCode":null,"errorMessage":"abigen generation failed","messagePattern":"abigen generation failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/fuels-macros/src/lib.rs","lineNumber":40,"sourceCode":"/// `ProgramType` is either `Contract`, `Script` or `Predicate`.\n///\n/// `ABI_SOURCE` is a string literal representing either a path to the JSON ABI\n/// file or the contents of the JSON ABI file itself.\n///\n///```text\n/// abigen!(Contract(\n///         name = \"MyContract\",\n///         abi = \"packages/fuels/tests/contracts/token_ops/out/release/token_ops-abi.json\"\n///     ));\n///```\n///\n/// More details can be found in the [`Fuel Rust SDK Book`](https://fuellabs.github.io/fuels-rs/latest)\n#[proc_macro]\npub fn abigen(input: TokenStream) -> TokenStream {\n    let targets = parse_macro_input!(input as MacroAbigenTargets);\n\n    Abigen::generate(targets.into(), false)\n        .expect(\"abigen generation failed\")\n        .into()\n}\n\n#[proc_macro]\npub fn wasm_abigen(input: TokenStream) -> TokenStream {\n    let targets = parse_macro_input!(input as MacroAbigenTargets);\n\n    Abigen::generate(targets.into(), true)\n        .expect(\"abigen generation failed\")\n        .into()\n}\n\n/// Used to reduce boilerplate in integration tests.\n///\n/// More details can be found in the [`Fuel Rust SDK Book`](https://fuellabs.github.io/fuels-rs/latest)\n#[proc_macro]\npub fn setup_program_test(input: TokenStream) -> TokenStream {\n    let test_program_commands = parse_macro_input!(input as TestProgramCommands);","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/FuelLabs/fuels-rs/blob/d9a250a51818dda64bfeb5ef7cc19cf27bdcd623/packages/fuels-macros/src/lib.rs#L22-L58","documentation":"abigen! is a proc macro: it parses the macro input, loads the ABI file(s) from disk, and runs bindings generation (Abigen::generate). Any failure anywhere in that pipeline is collapsed into this single .expect at compile time, so the message alone does not say which step failed.","triggerScenarios":"Compiling a crate whose abigen! references an abi path that does not exist relative to the crate root (commonly out/release/*-abi.json missing because forc build was not run), malformed macro syntax, unreadable or invalid JSON, or ABI constructs the generator does not support.","commonSituations":"Forgetting to run forc build before cargo build/test; moving or renaming contract directories; wrong relative path; forc/fuels version mismatch.","solutions":["Run forc build (forc build --release) so the ABI json exists at the path given to abigen!","Fix the path: it resolves relative to the crate root, e.g. \"tests/contracts/my_contract/out/release/my_contract-abi.json\"","Validate the file is readable, valid JSON (jq empty or similar)","cargo clean and rebuild if stale artifacts are suspected; update fuels to the version matching your forc"],"exampleFix":"// before: path does not exist because the contract was never built\nabigen!(Contract(name = \"MyContract\", abi = \"out/release/token_ops-abi.json\"));\n\n// after: build first, and point at the real artifact\n// (shell) forc build --release\nabigen!(Contract(name = \"MyContract\", abi = \"tests/contracts/token_ops/out/release/token_ops-abi.json\"));","handlingStrategy":"validation","validationCode":"# (shell) make sure the ABI exists and is valid JSON before cargo build\nforc build --release\ntest -f tests/contracts/my_contract/out/release/my_contract-abi.json \\\n  && jq empty tests/contracts/my_contract/out/release/my_contract-abi.json","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Chain forc build && cargo test in a justfile/Makefile so contracts are always built first","Keep abi paths stable and relative to the crate root","Commit generated ABIs when CI cannot run forc","Pin the forc/fuels version pair"],"tags":["proc-macro","abigen","compile-time","abi"],"backgroundTag":null,"analyzedSha":"d9a250a51818dda64bfeb5ef7cc19cf27bdcd623","analyzedAt":"2026-08-16T09:49:30.618Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}