Search code examples
substrate

Substrate node template build Error E0277


I followed this tutorial.
https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup
when I run cargo build --release then got the error:

error[E0277]: `[parity_wasm::elements::Instruction; 15]` is not an iterator
   --> /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/pwasm-utils-0.18.2/src/stack_height/mod.rs:300:23
    |
300 |                 new_instrs.extend(new_seq);
    |                                   ^^^^^^^
    |                                   |
    |                                   expected an implementor of trait `IntoIterator`
    |                                   help: consider borrowing here: `&new_seq`
    |
    = note: the trait bound `[parity_wasm::elements::Instruction; 15]: IntoIterator` is not satisfied
    = note: required because of the requirements on the impl of `IntoIterator` for `[parity_wasm::elements::Instruction; 15]`

   Compiling unsigned-varint v0.7.0

I used Ubuntu & cargo version 1.51.0
Thank you


Solution

  • Whenever in doubt about the nightly version that is know to work, it is best to look at the shell.nix file on substrate at the tag/release/branch you are building against. For example, on master as of 2021-10-11:

      rust-nightly = with nixpkgs; ((rustChannelOf { date = "2021-09-10"; channel = "nightly"; }).rust.override {...}
    

    You can downgrade your toolchain (for wasm target too, needed for substrate builds) with any version using:

    rustup uninstall nightly
    rustup install nightly-<YYYY-MM-DD>
    rustup target add wasm32-unknown-unknown --toolchain nightly-<YYYY-MM-DD>
    

    Then build with:

    WASM_BUILD_TOOLCHAIN=nightly-<yyyy-MM-dd> cargo build --release