Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: duplicate lang item in crate `std` (which `arrayvec` depends on): `panic_impl`

Tags:

rust

substrate

I am using the latest rust toolchain, compiler the pallet-ibc at the branch: features/dv-ics20 : https://github.com/octopus-network/substrate-ibc, this gives the blow error.

     Compiling ibc v0.12.0 (/Volumes/Seagate Basic/octopus/ibc-rs/modules)
  error: duplicate lang item in crate `std` (which `arrayvec` depends on): `panic_impl`.
    |
    = note: the lang item is first defined in crate `sp_io` (which `sp_application_crypto` depends on)
    = note: first definition in `sp_io` loaded from /Volumes/Seagate Basic/octopus/substrate-ibc/target/debug/wbuild/pallet-ibc/target/wasm32-unknown-unknown/release/deps/libsp_io-af37dfe030ffe3a3.rmeta
    = note: second definition in `std` loaded from /Users/suyinrong/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-d9a8e4ca4a56d589.rlib

  error: duplicate lang item in crate `std` (which `arrayvec` depends on): `oom`.
    |
    = note: the lang item is first defined in crate `sp_io` (which `sp_application_crypto` depends on)
    = note: first definition in `sp_io` loaded from /Volumes/Seagate Basic/octopus/substrate-ibc/target/debug/wbuild/pallet-ibc/target/wasm32-unknown-unknown/release/deps/libsp_io-af37dfe030ffe3a3.rmeta
    = note: second definition in `std` loaded from /Users/suyinrong/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libstd-d9a8e4ca4a56d589.rlib

My env:

Default host: aarch64-apple-darwin
rustup home:  /Users/suyinrong/.rustup

installed toolchains
--------------------

stable-aarch64-apple-darwin
nightly-2022-02-17-aarch64-apple-darwin
nightly-aarch64-apple-darwin
1.58-aarch64-apple-darwin (default)

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
wasm32-unknown-unknown

active toolchain
----------------

1.58-aarch64-apple-darwin (default)
rustc 1.58.1 (db9d1b20b 2022-01-20)
like image 341
D.Davirain Avatar asked May 01 '26 14:05

D.Davirain


1 Answers

If you have a local crate, add this in the lib.rs:

#![cfg_attr(not(feature = "std"), no_std)]

If you use remote crates, add default-features = false, in your Cargo.toml. For example:

imported_crate = { git = "...", default-features = false, branch = "..." }

see more details about no_std: https://substrate.stackexchange.com/questions/1307/how-to-resolve-duplicate-lang-item-error

like image 158
Russo Avatar answered May 04 '26 14:05

Russo