【问题标题】:error: duplicate lang item in crate `sp_io`错误:板条箱`sp_io`中的重复语言项
【发布时间】:2021-10-19 05:20:11
【问题描述】:

我正在构建一个基于基板的项目,当我运行 cargo build --release 时看到一些错误。 runtime 的 Toml 文件如下 -

runtime/Cargo.toml

[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.0.0'

[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'

[dependencies.frame-executive]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.frame-system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.frame-system-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.frame-system-rpc-runtime-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.hex-literal]
optional = true
version = '0.3.1'

[dependencies.pallet-aura]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.pallet-balances]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.pallet-grandpa]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'

[dependencies.pallet-randomness-collective-flip]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.pallet-sudo]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.pallet-carpooling]
default-features = false
path = '../pallets/carpooling'
version = '3.0.0'

[dependencies.pallet-timestamp]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.pallet-transaction-payment]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.pallet-transaction-payment-rpc-runtime-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-api]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-block-builder]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-consensus-aura]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '0.9.0'

[dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-inherents]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-offchain]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-runtime]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-session]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-std]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-transaction-pool]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.sp-version]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
edition = '2018'
homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template-runtime'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[build-dependencies.substrate-wasm-builder]
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '4.0.0'

# local dependencies
[dependencies]
carpooling-runtime-api = {version='3.0.0', default-features = false, path = "../pallets/carpooling/runtime-api" }

[features]
default = ['std']
runtime-benchmarks = [
    'frame-benchmarking',
    'frame-support/runtime-benchmarks',
    'frame-system-benchmarking',
    'frame-system/runtime-benchmarks',
    'hex-literal',
    'pallet-balances/runtime-benchmarks',
    'pallet-carpooling/runtime-benchmarks',
    'pallet-timestamp/runtime-benchmarks',
    'sp-runtime/runtime-benchmarks',
]
std = [
    'codec/std',
    'frame-executive/std',
    'frame-support/std',
    'frame-system-rpc-runtime-api/std',
    'frame-system/std',
    'pallet-aura/std',
    'pallet-balances/std',
    'pallet-grandpa/std',
    'pallet-randomness-collective-flip/std',
    'pallet-sudo/std',
    'pallet-carpooling/std',
    'pallet-timestamp/std',
    'pallet-transaction-payment-rpc-runtime-api/std',
    'pallet-transaction-payment/std',
    'sp-api/std',
    'sp-block-builder/std',
    'sp-consensus-aura/std',
    'sp-core/std',
    'sp-inherents/std',
    'sp-offchain/std',
    'sp-runtime/std',
    'sp-session/std',
    'sp-std/std',
    'sp-transaction-pool/std',
    'sp-version/std',
    'carpooling-runtime-api/std'
]

我看到的错误如下所示。

 error: duplicate lang item in crate `sp_io` (which `sp_application_crypto` 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 /home/knoldus/Project/Carpooling-Chain/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-45b30cc25a28bf9d.rmeta
    = note: second definition in `sp_io` loaded from /home/knoldus/Project/Carpooling-Chain/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-0d2b8d6c1590e857.rmeta

  error: duplicate lang item in crate `sp_io` (which `sp_application_crypto` 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 /home/knoldus/Project/Carpooling-Chain/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-45b30cc25a28bf9d.rmeta
    = note: second definition in `sp_io` loaded from /home/knoldus/Project/Carpooling-Chain/target/release/wbuild/node-template-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-0d2b8d6c1590e857.rmeta

pallets/carpooling/Cargo.toml

[dev-dependencies.sp-core]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'


[dev-dependencies.sp-runtime]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'
[dependencies.codec]
default-features = false
features = ['derive']
package = 'parity-scale-codec'
version = '2.0.0'

[dependencies.frame-benchmarking]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
optional = true
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.1.0'

[dependencies.frame-support]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[dependencies.frame-system]
default-features = false
git = 'https://github.com/paritytech/substrate.git'
rev = 'd6c33e7ec313f9bd5e319dc0a5a3ace5543f9617'
version = '3.0.0'

[features]
default = ['std']
runtime-benchmarks = ['frame-benchmarking']
std = [
    'codec/std',
    'frame-support/std',
    'frame-system/std',
    'frame-benchmarking/std',
]
try-runtime = ['frame-support/try-runtime']

[package]
authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
description = 'FRAME pallet template for defining custom runtime logic.'
edition = '2018'
homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'pallet-carpooling'
readme = 'README.md'
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
version = '3.0.0'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

谁能帮我解决这个问题?

【问题讨论】:

  • 能否添加cargo tree -i sp_io的输出?
  • 这里是输出
  • error: There are multiple 'sp-io' packages in your project, and the specification 'sp-io' is ambiguous. Please re-run this command with '-p &lt;spec&gt;' where '&lt;spec&gt;' is one of the following: https://github.com/rust-lang/crates.io-index#sp-io:3.0.0 https://github.com/paritytech/substrate.git#sp-io:3.0.0
  • @Cerberus 看看你能不能帮忙

标签: rust runtime rust-cargo substrate toml


【解决方案1】:

我认为您应该再次取消注释运行时配置中的自定义托盘之一,例如Template:pallet-template::{Pallet,Call,Storage,Event&lt;T&gt;}cargo check,以便您可以检查导致错误的修改托盘。或者您可以显示所有定制托盘的 Cargo.toml。我会帮你的。

【讨论】:

  • 我在问题中添加了自定义托盘的Cargo.toml
  • 看看你能不能帮忙
  • 你能在你的自定义托盘中添加 Cargo.toml [dependencies.sp-io] default-features = false version = '3.0.0'
  • 谢谢,以这种格式添加依赖解决了问题。
【解决方案2】:

通常这意味着您在上游有多个版本的相同基板依赖项。作为第一步,确保所有cargo.toml 文件具有相同的semver 兼容版本(理想情况下完全相同)。然后执行cargo clean删除 cargo.lock 文件。尝试再次构建。如果还是不行,你可能需要通过cargo update -p foo -p barupdate specific packages manually

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 2015-05-08
    相关资源
    最近更新 更多