3

I am experiencing an issue when using cargo-contract (version 1.5.1) to build a project (command: cargo +nightly contract build). The specified toolchain is not being recognized, and the process is forcibly calling nightly-2022-06-30 instead.

This occurs on both my M2 MacOS and Ubuntu (within the Windows11 WSL environment), suggesting that the problem is likely not device-dependent. I have followed the installation instructions as outlined in Astar Doc's Ink! Environment (https://docs.astar.network/docs/build/environment/ink_environment/).

The issue surfaces when building a flipper created by cargo contract new flipper. Interestingly, the problem does not occur when I install cargo-contract V2, suggesting that the issue might specifically be with V1.5.1.

There are no elements that could potentially influence the toolchain specification (such as environment variables or specification via the rust-toolchain file). Even after uninstalling nightly-2022-06-30 using rustup toolchain uninstall, the process still attempts to call this version.

Here is the corresponding log:

yasuyasu@mocomocha:~/astar/flipper$ cargo +nightly contract build
2023-05-13T12:50:30.989598Z  INFO cargo_contract::crate_metadata: Fetching cargo metadata for Cargo.toml
2023-05-13T12:50:31.050626Z  INFO cargo_contract::util: Invoking cargo: "/home/yasuyasu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "tree" "-i" "parity-scale-codec" "--duplicates"
2023-05-13T12:50:31.070036Z  INFO cargo_contract::util: Invoking cargo: "/home/yasuyasu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "tree" "-i" "scale-info" "--duplicates"
2023-05-13T12:50:31.088857Z  INFO cargo_contract::cmd::build: Contract version: Version { major: 3, minor: 4, patch: 0 }
 [1/5] Checking ink! linting rules
2023-05-13T12:50:31.113119Z  INFO cargo_contract::util: Invoking cargo: cd "/home/yasuyasu/astar/flipper" && DYLINT_LIBRARY_PATH="/tmp/cargo-contract-dylint_CAz4e7" "/home/yasuyasu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "dylint" "--lib" "ink_linting" "--manifest-path=/home/yasuyasu/astar/flipper/Cargo.toml"
Checking with toolchain `nightly-2022-06-30-x86_64-unknown-linux-gnu`
    Checking scale-info v2.6.0
error[E0658]: `let...else` statements are unstable
   --> /home/yasuyasu/.cargo/registry/src/github.com-1ecc6299db9ec823/scale-info-2.6.0/src/portable.rs:130:17
    |
130 | /                 let Some(ty) = &param.ty else {
131 | |                     continue
132 | |                 };
    | |__________________^
    |
    = note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
    = help: add `#![feature(let_else)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `scale-info` due to previous error
Error: Compilation failed with toolchain `nightly-2022-06-30-x86_64-unknown-linux-gnu`

Caused by:
    command failed: CLIPPY_DISABLE_DOCS_LINKS="null" DYLINT_LIBS="[\"/tmp/cargo-contract-dylint_CAz4e7/libink_linting@nightly-2022-06-30-x86_64-unknown-linux-gnu.so\"]" RUSTC_WORKSPACE_WRAPPER="/home/yasuyasu/.dylint_drivers/nightly-2022-06-30-x86_64-unknown-linux-gnu/dylint-driver" RUSTUP_TOOLCHAIN="nightly-2022-06-30-x86_64-unknown-linux-gnu" "cargo" "check" "--target-dir" "/home/yasuyasu/astar/flipper/target/dylint/target/nightly-2022-06-30-x86_64-unknown-linux-gnu" "--manifest-path" "/home/yasuyasu/astar/flipper/Cargo.toml"
ERROR: `cd "/home/yasuyasu/astar/flipper" && DYLINT_LIBRARY_PATH="/tmp/cargo-contract-dylint_CAz4e7" "/home/yasuyasu/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo" "dylint" "--lib" "ink_linting" "--manifest-path=/home/yasuyasu/astar/flipper/Cargo.toml"` failed with exit code: Some(1)
yasuyasu@mocomocha:~/astar/flipper$
5
  • 1
    Did you try to override it with the WASM_BUILD_TOOLCHAIN env var? Commented May 13, 2023 at 14:09
  • 1
    Thanks for reply. I tried export WASM_BUILD_TOOLCHAIN=nightly-2023-01-01 But result was same.. In this line of log, I don't know why check is carried out by nightly-2022-06-30
    – Yasu Yasu
    Commented May 13, 2023 at 14:44
  • 1
    [1/5] Checking ink! linting rules 2023-05-13T14:42:50.667586Z INFO cargo_contract::util: Invoking cargo: cd "/Users/yasuyasu/hack/astar/develop/flipper" && DYLINT_LIBRARY_PATH="/var/folders/jr/8pgwdjss1k148znsrq610j800000gn/T/cargo-contract-dylint_Mcn2A3" "/Users/yasuyasu/.rustup/toolchains/nightly-2023-01-01-aarch64-apple-darwin/bin/cargo" "dylint" "--lib" "ink_linting" "--manifest-path=/Users/yasuyasu/hack/astar/develop/flipper/Cargo.toml" Checking with toolchain nightly-2022-06-30-aarch64-apple-darwin`
    – Yasu Yasu
    Commented May 13, 2023 at 14:44
  • rustup override set nightly-2023-01-01-x86_64-unknown-linux-gnu && rustup show Commented May 15, 2023 at 8:41
  • do you have any symlinks active in that could be causing +nightly to use a different version? (i.e. what is the output of ls -al /home/yasuyasu/.rustup/toolchains? note: i had a similar issue because i was doing this github.com/ltfschoen/InkTemplate/blob/main/docker/run.sh#L74. what was the output of running rustc +nightly version Commented Jun 20, 2023 at 11:32

1 Answer 1

0

This failure occurs during the linting process, which in the case of cargo-contract 1.5.1 uses a hardcoded toolchain nightly-2022-06-30: https://github.com/paritytech/cargo-contract/blob/v1.x.x/ink_linting/rust-toolchain.toml

The workaround is to avoid using linting by running: cargo contract build --skip-linting

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.