0

I was trying to use this ansi_term dependency in my project/precompiles/utils/src/lib.rs.

Here is my file structure:

my_parachain/
├── ...
└──precompiles/utils
     ├── macro
     ├── src/lib.rs
     └── Cargo.toml

after adding the following in the Cargo.toml above

ansi_term = "0.12.1"

All can compile. ansi_term was also found to be 0.12.1 in my Cargo.lock already before adding that in the Cargo.toml.

but when I want to use this ansi_term dependency by adding the following line in my project/precompiles/utils/src/lib.rs

use ansi_term::Colour;

then I got this error:

 error: duplicate lang item in crate `std` (which `ansi_term` depends on): `panic_impl`.
    |
    = note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
    = note: first definition in `sp_io` loaded from .../target/release/wbuild/hero-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-825169ab8c4ddb77.rmeta
    = note: second definition in `std` loaded from /home/user2038/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-a237209e92b55a70.rlib

  error: duplicate lang item in crate `std` (which `ansi_term` depends on): `oom`.
    |
    = note: the lang item is first defined in crate `sp_io` (which `frame_support` depends on)
    = note: first definition in `sp_io` loaded from .../target/release/wbuild/hero-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-825169ab8c4ddb77.rmeta
    = note: second definition in `std` loaded from /home/user2038/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-a237209e92b55a70.rlib

  warning: `precompile-utils` (lib) generated 1 warning
  error: could not compile `precompile-utils` due to 2 previous errors; 1 warning emitted

But if I remove use ansi_term::Colour; in precompiles/utils/src/lib.rs, then all can compile again.

What went wrong???

2
  • 1
    Where do you want to use this crate? In a pallet or just in a test? Commented Sep 15, 2022 at 13:06
  • @OliverTale-Yazdi in my project/precompiles/utils/src/lib.rs, which is for running precompile codes, not a pallet nor a test
    – Russo
    Commented Sep 15, 2022 at 13:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.