Dfx 0.23.0: build fail, Caused by: No crate `xxxxxx` found

$ dfx build idempotent-proxy-canister
Building canisters...
Checking for vulnerabilities in rust canisters.
    Fetching advisory database from https://github.com/RustSec/advisory-db.git
      Loaded 660 security advisories (from /home/tanguy/.cargo/advisory-db)
    Updating crates.io index
    Scanning Cargo.lock for vulnerabilities (308 crate dependencies)
Audit found no vulnerabilities.
Error: Failed while trying to build all canisters.
Caused by: The build step failed for canister 'bkyz2-fmaaa-aaaaa-qaaaq-cai' (idempotent-proxy-canister)
Caused by: Failed to build Rust canister 'idempotent-proxy-canister'.
Caused by: Failed to create <Type>CanisterInfo for canister 'idempotent-proxy-canister'.
Caused by: No crate `idempotent-proxy-canister` found`

Downgrading my dfx to 0.22.0 made it work. Now I don’t know how to fix it with dfx 0.23.0

Issue from github:

I can reproduce the issue but haven’t found the cause.

dfx v0.23 cannot handle Rust canisters with hyphens in the crate name.
Try changing name in Cargo.toml and package in dfx.json to idempotent_proxy_canister.

1 Like

I found a similar issue here, so I have commented on it, including the part that I think might be the cause.

dfx can handle hyphens in the package name, but it assumes the wrong crate name. For a stopgap, you do not need to change your Cargo package names, you just need to use dfx’s new field for the crate name.

"package": "idempotent-proxy-canister",
"crate": "idempotent_proxy_canister",

This regression will be fixed in the next release.

3 Likes

As of 0.24 hyphens are correctly handled.

4 Likes