0

I am following this tutorial and when I add this code to my untime/Cargo.toml

[features]
default = ["std"]
std = [
  "codec/std",
  "scale-info/std",
  "frame-executive/std",
  "frame-support/std",
  "frame-system-rpc-runtime-api/std",
  "frame-system/std",
  "pallet-aura/std",
  "pallet-balances/std",
  "pallet-contracts/std",
  "pallet-contracts-primitives/std",
]

but when I test it out with cargo check -p node-template-runtime I get this error:

error: failed to load manifest for workspace member `/home/bosr/rust/substrate-node-template/node`

Caused by:
  failed to parse manifest at `/home/bosr/rust/substrate-node-template/node/Cargo.toml`

Caused by:
  feature `std` includes `codec/std`, but `codec` is not a dependency

What is the name of the dependency I need to add to make it work? I tried codec but the compiler tells me error: no matching package named codec found

2 Answers 2

0

By default codec dependency exists, if you doesn't find it you can use this codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }

enter image description here

0
0

This is a Rust question.

If you want to enable some features of a crate. Apparently, you must ensure you have that crate already.


# you need to add x first
#
# usually, people enable std feature by default
# so, you probably need to disable the default-features here 
x = { version = "0.1.0", default-features = false }

[features]
# then enable the std here
std = ["x/std"]
2
  • codec = is an alias name. The real name is parity-scale-codec. I recommend you learn some Rust first. There is no "correct" format. Just because we use an alias name here. You could also write parity-scale-codec = { version = "3.0.0", default-features = false, features = ["derive"] }
    – aurexav
    Commented Sep 24, 2022 at 16:25
  • IMHO, that answer is not good. He didn't tell you why you need to write in this way. Anyway, have some Rust first. :)
    – aurexav
    Commented Sep 24, 2022 at 16:29

Your Answer

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

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