Forc/Rust project fails to compile on release mode, but debug mode works

Hey everyone. I’ve encountered an issue recently where the dev (debug) build of a Rust + Forc project works, but the release build (forc build --release && cargo build --release) fails to compile. To provide a bit more details, the issue is in the abigen! macro mostly. In debug, it generates ABI properly, but in the release build I get this:

error: proc macro panicked
  --> src/orderbook_utils.rs:17:1
   |
17 | / abigen!(Contract(
18 | |     name = "OrderbookContract",
19 | |     abi = "contract/out/debug/orderbook-abi.json"
20 | | ));
   | |__^
   |
   = help: message: failed to parse JSON ABI from string: "failed to read artifact JSON file with path /home/raven/gitproj/complabs/spark-matcher-rs/contract/out/debug/orderbook-abi.json No such file or directory (os error 2)"

error[E0432]: unresolved import `self::abigen_bindings`
  --> src/orderbook_utils.rs:15:11
   |
15 | use self::abigen_bindings::orderbook_contract_mod;
   |           ^^^^^^^^^^^^^^^ could not find `abigen_bindings` in `self`

error[E0412]: cannot find type `OrderbookContract` in this scope
  --> src/orderbook_utils.rs:23:19

Let me know what else I can provide in terms of info to help you investigate this.

When you compile the project with forc build --release, you should change the path of the abi file.

In your case, the new path would be abi = "contract/out/release/orderbook-abi.json"

1 Like

Oh. That was… Uhm, thanks for the help! Yeah, of course it works with the release path.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.