Building process fails for icrc-ledger-types

Hello dfinity team, I’ve been using packages/icrc-ledger-types as a dependency in my rust project for a long time but since yesterday the build process fails with the following error:

error[E0432]: unresolved import `strum::EnumIter`
   --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:17:19
    |
17  | use strum::{self, EnumIter};
    |                   ^^^^^^^^ no `EnumIter` in the root
    |
note: found an item that was configured out
   --> /home/asjn3e/.cargo/registry/src/index.crates.io-6f17d22bba15001f/strum-0.26.3/src/lib.rs:252:5
    |
252 |     EnumIter,
    |     ^^^^^^^^

error[E0432]: unresolved imports `strum::Display`, `strum::EnumString`
   --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:18:13
    |
18  | use strum::{Display, EnumString};
    |             ^^^^^^^  ^^^^^^^^^^ no `EnumString` in the root
    |             |
    |             no `Display` in the root
    |
    = help: consider importing one of these items instead:
            core::fmt::Display
            std::ffi::os_str::Display
            std::fmt::Display
            std::path::Display
note: found an item that was configured out
   --> /home/asjn3e/.cargo/registry/src/index.crates.io-6f17d22bba15001f/strum-0.26.3/src/lib.rs:249:5
    |
249 |     Display,
    |     ^^^^^^^
note: found an item that was configured out
   --> /home/asjn3e/.cargo/registry/src/index.crates.io-6f17d22bba15001f/strum-0.26.3/src/lib.rs:255:5
    |
255 |     EnumString,
    |     ^^^^^^^^^^

error: cannot find attribute `strum` in this scope
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:25:7
   |
25 |     #[strum(serialize = "icrc1_transfer")]
   |       ^^^^^
   |
note: `strum` is imported here, but it is a crate, not an attribute
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:17:13
   |
17 | use strum::{self, EnumIter};
   |             ^^^^

error: cannot find attribute `strum` in this scope
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:27:7
   |
27 |     #[strum(serialize = "icrc2_approve")]
   |       ^^^^^
   |
note: `strum` is imported here, but it is a crate, not an attribute
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:17:13
   |
17 | use strum::{self, EnumIter};
   |             ^^^^

error: cannot find attribute `strum` in this scope
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:29:7
   |
29 |     #[strum(serialize = "icrc2_transfer_from")]
   |       ^^^^^
   |
note: `strum` is imported here, but it is a crate, not an attribute
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:17:13
   |
17 | use strum::{self, EnumIter};
   |             ^^^^

    Checking ic-ledger-canister-core v0.9.0 (https://github.com/dfinity/ic.git#d6957f09)
    Checking rand_chacha v0.3.1
error[E0277]: the trait bound `Icrc21Function: FromStr` is not satisfied
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:54:18
   |
54 |                 .parse::<Icrc21Function>()
   |                  ^^^^^ the trait `FromStr` is not implemented for `Icrc21Function`
   |
   = help: the following other types implement trait `FromStr`:
             Account
             BigInt
             BigUint
             IpAddr
             Ipv4Addr
             Ipv6Addr
             ObjectIdentifier
             OsString
           and 51 others

error[E0599]: no variant or associated item named `iter` found for enum `Icrc21Function` in the current scope
  --> /home/asjn3e/.cargo/git/checkouts/ic-ca00ee28655ee32e/d6957f0/packages/icrc-ledger-types/src/icrc21/lib.rs:55:261
   |
24 | enum Icrc21Function {
   | ------------------- variant or associated item `iter` not found for this enum
...
55 |                 .map_err(|err| Icrc21Error::UnsupportedCanisterCall(ErrorInfo {                    description: format!("The function provided is not supported: {}.\n Supported functions for ICRC-21 are: {:?}.\n Error is: {:?}",icrc21_function,Icrc21Function::iter()....
   |                                                                                                                                                                                                                                                                     ^^^^ variant or associated item not found in `Icrc21Function`
   |
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following traits define an item `iter`, perhaps you need to implement one of them:
           candidate #1: `IntoEnumIterator`
           candidate #2: `VariantIterator`

I assume it is happening due to an update in ic repository since I’ve imported the dependency directly from Dfinity’s github.

This is generally not a great idea since the repo uses Bazel instead of cargo as the main build tool. When things work with cargo it’s more or less a happy accident.

Is there a reason why you are not using the published version?

I mean, i needed to use these dependencies as well

ic-crypto-sha2={ git = "https://github.com/dfinity/ic.git"}
ic-management-canister-types = { git = "https://github.com/dfinity/ic.git" }
ic-crypto-secp256k1 = { git = "https://github.com/dfinity/ic.git" }
ic-utils-ensure = { git = "https://github.com/dfinity/ic.git" }
ic-icrc1-index-ng = { git = "https://github.com/dfinity/ic.git"}
ic-ethereum-types = { git = "https://github.com/dfinity/ic.git"}

I could not find published crates for some of them.
Do you have a better solutions?

Also cargo build was working properly fine for a long time but it stopped working after an update to the ic repository. I also found another commit for fixing cargo build.

However it’s still not fixed.

I just checked it again and it seems to be fixed, Thank you so much.

Glad to hear, but I don’t think anyone did anything on purpose :person_shrugging:

1 Like