gpt4 book ai didi

rust - 错误 : duplicate lang item in crate `sp_io`

转载 作者:行者123 更新时间:2023-12-05 01:28:17 27 4
gpt4 key购买 nike

我正在构建一个基于基板的项目,当我运行 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']

谁能帮我解决这个问题?

最佳答案

我的解决方案是将此添加到 lib.rs:

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

关于rust - 错误 : duplicate lang item in crate `sp_io` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68814981/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com