【问题标题】:error: duplicate lang item in crate `std` (which `arrayvec` depends on): `panic_impl`错误:在 crate `std` 中重复 lang 项(`arrayvec` 依赖):`panic_impl`
【发布时间】:2022-06-24 18:04:50
【问题描述】:

我正在使用最新的 rust 工具链,在分支处编译 Pallet-ibc:features/dv-ics20 : https://github.com/octopus-network/substrate-ibc,这给出了打击错误。

     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

我的环境:

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)

【问题讨论】:

  • 导致错误的命令是什么?这个 crate 是否是您的 Cargo.toml 中的一个依赖项,在使用 cargo build 构建时会导致问题?
  • 请在substrate stack exchange提出这个问题
  • 是的,只需运行cargo build
  • 问题是arrayvec 没有no_std功能被使用,但是没有 Cargo.toml 文件就无法判断是什么依赖导致了这种情况。
  • 是的,我找不到这个错误。

标签: rust substrate


【解决方案1】:

如果您有本地 crate,请将其添加到 lib.rs 中:

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

如果您使用远程 crate,请在您的 Cargo.toml 中添加 default-features = false,。例如:

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

查看更多关于no_std的详细信息:https://substrate.stackexchange.com/questions/1307/how-to-resolve-duplicate-lang-item-error

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-16
    • 2012-11-18
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-07
    相关资源
    最近更新 更多