Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve Substrate `duplicate lang item in crate 'std' (which 'myexternalcrate' depends on): 'panic_impl' conflict with sr-io

Tags:

substrate

I'm using an extern crate in my Substrate 1.0 runtime module (based on node-template) which gives a compile error of

duplicate lang item in crate 'std' (which 'myexternalcrate' depends on): 'panic_impl'.

= note: first defined in crate `sr_io` (which `node_template_runtime` depends on).

If I understand the message correctly then I think this might be a common problem if developers want to include external crates that rely on std features which already implemented in sr-io, but I'm not sure if that is correct.

I have seen this issue here, which appears to have been fixed in sr-io but that does not appear to be the cause here.

Is their another approach to resolve this?

EDIT: Adding in changes to Cargo.toml We are attempting to pull in crate called nacl

[dependencies]
nacl = {version = "0.3.0", default-features = false}

Added in lib.rs

extern crate nacl;

in the runtime module

use nacl::public_box::*;
like image 277
T9b Avatar asked Oct 16 '22 08:10

T9b


1 Answers

The crate you are trying to use (rust-nacl) does not support no_std, and thus cannot be used within the Substrate runtime environment.

The options are:

  • Find another crate which does support no_std and has similar functionality: https://crates.io/keywords/no_std
  • Update/Write a crate to support no_std (which may not be that bad depending on the crate).
like image 55
Shawn Tabrizi Avatar answered Oct 21 '22 00:10

Shawn Tabrizi