2

I am trying to add Frontier as a dependency in my substrate-parachain-template.

     Compiling sp-npos-elections v4.0.0-dev (https://github.com/paritytech/substrate?branch=polkadot-v0.9.25#3348e144)
  error: cannot find macro `vec` in this scope
     --> /home/user2038/.cargo/git/checkouts/substrate-7e08433d4c370a21/3348e14/primitives/npos-elections/src/reduce.rs:604:21
      |
  604 |                     let min_edge = vec![min_voter, min_target];
      |                                    ^^^
      |
      = note: consider importing one of these items:
              codec::alloc::vec
              crate::vec
              scale_info::prelude::vec
              sp_std::vec

  error: cannot find macro `vec` in this scope
    --> /home/user2038/.cargo/git/checkouts/substrate-7e08433d4c370a21/3348e14/primitives/npos-elections/src/phragmms.rs:52:20
     |
  52 |     let mut winners = vec![];
     |                       ^^^
     |
     = note: consider importing one of these items:
             codec::alloc::vec
             crate::vec
             scale_info::prelude::vec
             sp_std::vec

From this post https://stackoverflow.com/questions/70477868/substrate-cannot-find-type-vec-in-this-scope, perhaps I need to make a pallet to fix this error? That sounds weird...

It seems this solves it: https://users.rust-lang.org/t/whats-different-between-these-two-features-style/47292/5 with reference https://github.com/paritytech/substrate/blob/master/utils/wasm-builder/src/wasm_project.rs#L324-L349

but how can I apply that in my project???

Is there another solution? How can I solve this?

3 Answers 3

2

Check your deps std features.

I think you might missing something like xxx/std.

1
  • This is the right thing for me Commented Nov 7, 2022 at 15:54
1

I solved it by adding default-features = false, in my Frontier dependencies in my runtime/Cargo.toml

# Frontier
pallet-evm = { git = "https://github.com/paritytech/frontier", default-features = false, branch = "polkadot-v0.9.25" }

but strangely, in my node/Cargo.toml, there is no need to add that:

#Frontier
fp-rpc = { git = "https://github.com/paritytech/frontier", branch = "polkadot-v0.9.25" }
1
  • 2
    Node is client side. Runtime is runtime side.
    – AurevoirXavier
    Commented Aug 8, 2022 at 9:57
-1

I think the compiler actually already tells you what you need to do. vec![] is not included in any of the crates you are using. So in order to use it, you need to import it.

This is how this could look like:

    use codec::vec;

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.