2

I am working on a Substrate project and want to use the orml-traits and orml-tokens crates in my custom pallet. I have added these crates to my Cargo.toml:

orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, version = "0.4.0" }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", default-features = false, version = "0.4.0" }

My project uses sp-io version 7.0.0, but I'm facing a dependency conflict:

error[E0152]: 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/kianoush/projects/music-chain/target/debug/wbuild/kitchensink-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-3f01c569c1bdc73f.rmeta
= note: second definition in `sp_io` loaded from /home/kianoush/projects/music-chain/target/debug/wbuild/kitchensink-runtime/target/wasm32-unknown-unknown/release/deps/libsp_io-a6d4512a0b6fd246.rmeta

  For more information about this error, try `rustc --explain E0152`.
  warning: `pallet-dex` (lib) generated 2 warnings
  error: could not compile `pallet-dex` due to previous error; 2 warnings emitted
  warning: build failed, waiting for other jobs to finish...
warning: build failed, waiting for other jobs to finish...

How can I make orml-traits and orml-tokens compatible with sp-io version 7.0.0 in my Substrate project?

2
  • Try using 0.4.1-dev.
    – Bruno
    Apr 14 at 6:44
  • @Bruno i tried to use this version but i t dosent work
    – Mr Coder
    Apr 14 at 9:46

1 Answer 1

1

First and foremost, make sure you're not using the open-runtime-module-library from crates.io - it is super old

You can patch all the Substrate dependencies to make sure they are the same throughout your project.

For example, Acala is currently using polkadot-v0.9.38:

# substrate
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
....

And you can see they use a patch to override the substrate dependency with a specific revision which you can pick but make sure it has sp-io v7.0.0:

[patch."https://github.com/paritytech/substrate"]
frame-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" }
frame-benchmarking-cli = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" }
....

And you can see that in open-runtime-module-library there is a polkadot-v0.9.38 branch that has a patch:

[patch.'https://github.com/paritytech/substrate']
frame-benchmarking = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" }
frame-support = { git = "https://github.com/paritytech//substrate", rev = "18bb7c7c841b101c19a8d1881b893ae8e37de460" }
....

Notice that the revisions from the orml library and Acala's substrate dependencies match up: 18bb7c7c841b101c19a8d1881b893ae8e37de460 == 18bb7c7c841b101c19a8d1881b893ae8e37de460

Your project should now work.

If you're not familiar with how cargo's patch works:

Specifically what we used above is this:

1
  • thanks but actully i can not undrestand what should i do
    – Mr Coder
    Apr 14 at 20:03

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.