Substrate: build failed when running `cargo build --release`

Created on 30 Apr 2020  路  11Comments  路  Source: paritytech/substrate

I got the following error on Ubuntu 20.04 by running cargo build --release

Compiling sp-arithmetic v2.0.0-dev (/home/min/Projects/substrate/substrate/primitives/arithmetic)

error: this operation will panic at runtime
   --> /home/min/Projects/substrate/substrate/primitives/arithmetic/src/fixed64.rs:171:32
    |
171 |             return Fixed64::from_parts( self.0 / zero);
    |                                         ^^^^^^^^^^^^^ attempt to divide by zero
    |
    = note: `#[deny(unconditional_panic)]` on by default

error: aborting due to previous error

error: could not compile `sp-arithmetic`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

warning: build failed, waiting for other jobs to finish...
error: build failed

Most helpful comment

i had the same issue and i solved it using the nightly-2020-10-06 compiler version as the documentation says:

https://substrate.dev/docs/en/knowledgebase/getting-started/#webassembly-compilation

Then i run the command setting the env variable WASM_BUILD_TOOLCHAIN:

WASM_BUILD_TOOLCHAIN=nightly-2020-10-06 cargo build

All 11 comments

In master?

@bkchr yeah it's in master. But the same error happens even if I checkout other branches like v2.0.0-alpha.6.

$ git branch -v
* master c82a0f7b5 Remove background_tasks field in ServiceBuilder (#5830)

Which rust version are you using?

$ rustc --version
rustc 1.43.0 (4fb7144ed 2020-04-20)

I am going to get a substrate docker image in case there is something wrong with my local environment...

BTW I tried with another ubuntu 18.04 laptop and same error occurred.

I am having a similar error too.

error: failed to run custom build command fornode-template-runtime v2.0.0 (/Users/mba/substrate-node-template/runtime)`

Caused by:
process didn't exit successfully: /Users/mba/substrate-node-template/target/release/build/node-template-runtime-cae9ad6029c9f681/build-script-build (exit code: 1)
--- stdout
Executing build command: "rustup" "run" "nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/Users/mba/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"

--- stderr
Compiling wasm-build-runner-impl v1.0.0 (/Users/mba/substrate-node-template/target/release/wbuild-runner/node-template-runtime18348932773558219608)
Finished release [optimized] target(s) in 2.71s
Running /Users/mba/substrate-node-template/target/release/wbuild-runner/node-template-runtime18348932773558219608/target/x86_64-apple-darwin/release/wasm-build-runner-impl
Compiling sp-arithmetic v2.0.0
Compiling sp-core v2.0.0
error[E0282]: type annotations needed
--> /Users/mba/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
|
541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type
...
1595 | / implement_fixed!(
1596 | | FixedI64,
1597 | | test_fixed_i64,
1598 | | i64,
... |
1601 | | "_Fixed Point 64 bits signed, range = [-9223372036.854775808, 9223372036.854775807]_",
1602 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0282]: type annotations needed
--> /Users/mba/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
|
541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type
...
1604 | / implement_fixed!(
1605 | | FixedI128,
1606 | | test_fixed_i128,
1607 | | i128,
... |
1611 | | [-170141183460469231731.687303715884105728, 170141183460469231731.687303715884105727]_",
1612 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0282]: type annotations needed
--> /Users/mba/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
|
541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type
...
1614 | / implement_fixed!(
1615 | | FixedU128,
1616 | | test_fixed_u128,
1617 | | u128,
... |
1621 | | [0.000000000000000000, 340282366920938463463.374607431768211455]_",
1622 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0282.
error: could not compile sp-arithmetic

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
warning: build failed, waiting for other jobs to finish...
error: build failed`

I am using rustc 1.47.0 (18bf6b4f0 2020-10-07)

I am having a similar error too.

error: failed to run custom build command fornode-template-runtime v2.0.0 (/Users/mba/substrate-node-template/runtime)`

Caused by:
process didn't exit successfully: /Users/mba/substrate-node-template/target/release/build/node-template-runtime-cae9ad6029c9f681/build-script-build (exit code: 1)
--- stdout
Executing build command: "rustup" "run" "nightly" "cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/Users/mba/substrate-node-template/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--release"

--- stderr
Compiling wasm-build-runner-impl v1.0.0 (/Users/mba/substrate-node-template/target/release/wbuild-runner/node-template-runtime18348932773558219608)
Finished release [optimized] target(s) in 2.71s
Running /Users/mba/substrate-node-template/target/release/wbuild-runner/node-template-runtime18348932773558219608/target/x86_64-apple-darwin/release/wasm-build-runner-impl
Compiling sp-arithmetic v2.0.0
Compiling sp-core v2.0.0
error[E0282]: type annotations needed
--> /Users/mba/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
|
541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type
...
1595 | / implement_fixed!(
1596 | | FixedI64,
1597 | | test_fixed_i64,
1598 | | i64,
... |
1601 | | "_Fixed Point 64 bits signed, range = [-9223372036.854775808, 9223372036.854775807]_",
1602 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0282]: type annotations needed
--> /Users/mba/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
|
541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type
...
1604 | / implement_fixed!(
1605 | | FixedI128,
1606 | | test_fixed_i128,
1607 | | i128,
... |
1611 | | [-170141183460469231731.687303715884105728, 170141183460469231731.687303715884105727]_",
1612 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0282]: type annotations needed
--> /Users/mba/.cargo/registry/src/github.com-1ecc6299db9ec823/sp-arithmetic-2.0.0/src/fixed_point.rs:541:9
|
541 | let accuracy = P::ACCURACY.saturated_into();
| ^^^^^^^^ consider giving accuracy a type
...
1614 | / implement_fixed!(
1615 | | FixedU128,
1616 | | test_fixed_u128,
1617 | | u128,
... |
1621 | | [0.000000000000000000, 340282366920938463463.374607431768211455]_",
1622 | | );
| |__- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0282.
error: could not compile sp-arithmetic

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
warning: build failed, waiting for other jobs to finish...
error: build failed`

I am using rustc 1.47.0 (18bf6b4f0 2020-10-07)

Is the problem solved锛烮 am having the same error too.

i had the same issue and i solved it using the nightly-2020-10-06 compiler version as the documentation says:

https://substrate.dev/docs/en/knowledgebase/getting-started/#webassembly-compilation

Then i run the command setting the env variable WASM_BUILD_TOOLCHAIN:

WASM_BUILD_TOOLCHAIN=nightly-2020-10-06 cargo build

I had the same error

@hbulgarini suggestion fixed it 馃帀

after I changed the wasm target as well

rustup target add wasm32-unknown-unknown --toolchain nightly-2020-10-06

This solves it @manuelpolzhofer
rustup toolchain install nightly-2020-08-23
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-08-23
Then compile your node with this:
cargo +nightly-2020-08-23 build --release

@bkchr I try to build a kitchen node but got:

https://github.com/paritytech/substrate/issues/7150#issuecomment-748978039

There is any place where I can find versions of Rust and toolchains required to build the node?

twaszczyk@ktwtomwasnb:~/workspaces/recipes/nodes/kitchen-node$ git status 
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gregdhill picture gregdhill  路  5Comments

xlc picture xlc  路  5Comments

qalqi picture qalqi  路  3Comments

tomaka picture tomaka  路  4Comments

tomaka picture tomaka  路  5Comments