【问题标题】:Substrate node template build Error E0277基板节点模板构建错误 E0277
【发布时间】:2021-10-12 01:51:11
【问题描述】:

我按照本教程进行操作。
https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup
当我运行cargo build --release 时出现错误:

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

我使用的是 Ubuntu & cargo 版本 1.51.0
谢谢

【问题讨论】:

    标签: substrate


    【解决方案1】:

    似乎您的 rust nightly 工具链与上面编写的代码不兼容。您需要使用 nightly-2020-10-01 或其他版本的 nightly 工具链使用 rustup install nightly-2020-10-01 降级它

    【讨论】:

      【解决方案2】:

      当您对已知的夜间版本有疑问时,最好查看您正在构建的标签/发布/分支中的shell.nix file on substrate。例如,截至 2021 年 10 月 11 日在 master 上:

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

      您可以使用以下任何版本降级您的工具链(也适用于 wasm 目标,基板构建需要):

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

      然后构建:

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

      【讨论】:

      • 我在 shell.nix 上得到的版本是 toolchain = with nixpkgs; (rustChannelOf { date = "2021-09-14"; channel = "nightly"; }); 但我仍然得到错误 rustup default nightly-2021-09-14-x86_64-unknown-linux-gnu (default)
      • 错误做什么? rustup target add wasm32-unknown-unknown --toolchain nightly-&lt;YYYY-MM-DD&gt; ?
      • 不行,我把默认改成2021-09-14成功了,但是运行后出现同样的错误cargo build --release好像是shell.nix上的版本不对。
      • 在 Github 上的一些 repo 中,没有 shell.nix 文件。我还能在哪里找到这个版本?
      • 我跑成功了cargo +nightly-2021-09-14-x86_64-unknown-linux-gnu build --release谢谢!
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多