build failed in substrate.dev Ink! tutorial. sp-aritmetic lack of type? [closed] - rust

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
My build has failed.
Everything looked good up until I tested my contract with the command:
cargo +nightly test
I got error [E0282]
Here is the whole error report:
error[E0282]: type annotations needed
--> /home/mal/.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
--> /home/mal/.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
--> /home/mal/.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`
This is part of a wider tutorial.
I believe rust is updated.
The problem seems to be the macro sp-aritmetic, however I am not sure how to give it a "type". My rust is non-existent...
Really eager to get into Ink! so any help is appreciated.

The cause of that error is a regression in the rust nightly compiler starting with version 2020-10-06. You need to rustup toolchain install 2020-10-05 and use that one for building your runtime until this issue is resolved. Usually, the latest nightly is automatically used to build your runtime. You can override this behaviour by setting the WASM_BUILD_TOOLCHAIN environment variable. In this case:
export WASM_BUILD_TOOLCHAIN='nightly-2020-10-05'
In case of building a contract with cargo contract you should use:
cargo +nightly-2020-10-05 contract build

Related

Rust compilation errors on installaton of libcst on alpine python

trying to install python modules on alpine linux using 3.7.9 image of alpine-python
Not able to find any solution on how to get the below issues resolved, any assistance would help a lot.
error[E0658]: or-patterns syntax is experimental
6908 --> libcst/src/tokenizer/core/mod.rs:944:25
6909 |
6910 944 | / '\n'
6911 945 | | | '\\'
6912 946 | | | '\''
6913 947 | | | '"'
6914 ... |
6915 958 | | | 'u'
6916 959 | | | 'U',
6917 | |_____________________________^
6918 |
6919 = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
6920
6921 error[E0658]: or-patterns syntax is experimental
6922 --> libcst/src/tokenizer/core/mod.rs:976:33
6923 |
6924 976 | if let Some('"' | '\'') = self.text_pos.peek() {
6925 | ^^^^^^^^^^
6926 |
6927 = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
6928
6929 error[E0658]: or-patterns syntax is experimental
6930 --> libcst/src/parser/grammar.rs:3203:14
6931 |
6932 3203 | e # (Expression::Integer(_) | Expression::Float(_)) => Ok(e),
6933 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6934 |
6935 = note: see issue #54883 <https://github.com/rust-lang/rust/issues/54883> for more information
6936
6937 error[E0658]: use of unstable library feature 'split_inclusive'
6938 --> libcst/src/tokenizer/whitespace_parser.rs:84:26
6939 |
6940 84 | lines: input.split_inclusive(default_newline).collect(),
6941 | ^^^^^^^^^^^^^^^
6942 |
6943 = note: see issue #72360 <https://github.com/rust-lang/rust/issues/72360> for more information
6944
6945 error: aborting due to 4 previous errors
6946
6947 For more information about this error, try `rustc --explain E0658`.
6948 error: could not compile `libcst`.
6949
6950 Caused by:
6953 error: `cargo rustc --lib --message-format=json-render-diagnostics --manifest-path native/libcst/Cargo.toml --release -v --features pyo3/extension-module -- --crate-type cdylib` failed with code 101
6954 [end of output]
6955
6956 note: This error originates from a subprocess, and is likely not a problem with pip.
6957 ERROR: Failed building wheel for libcst
“use of unstable library feature” and “syntax is experimental” indicate you are using a version of the Rust compiler older than that required for this program.
or_patterns was stabilized in Rust 1.53. split_inclusive was stabilized in Rust 1.51 (look at the version number on the right side of the method entry).
You will need to install Rust 1.53 or newer. Right now, you are using a version that is more than a year old.

compiling and cpu architecture error for apple despite being on an ubuntu?

I'm trying to compile something from a github branch. I'm on an ubuntu.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
with the following configuration.
❯ rustup -V
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.61.0-nightly (d53246fed 2022-03-25)`
❯ cargo -V
cargo 1.61.0-nightly (109bfbd 2022-03-17)
❯ rustup default
nightly-x86_64-unknown-linux-gnu (default)
however when trying to compile I get this error.
error: no rules expected the token `aarch64_apple`
--> /home/ahdee/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/src/cpu.rs:257:13
|
165 | macro_rules! features {
| --------------------- when calling this macro
...
257 | aarch64_apple: true,
| ^^^^^^^^^^^^^ no rules expected this token in macro call
error[E0425]: cannot find value `AES` in module `cpu::arm`
--> /home/ahdee/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/src/aead/aes.rs:381:65
|
381 | if cpu::intel::AES.available(cpu_features) || cpu::arm::AES.available(cpu_features) {
| ^^^ not found in `cpu::arm`
|
help: consider importing this constant
|
15 | use crate::cpu::intel::AES;
|
error[E0425]: cannot find value `PMULL` in module `cpu::arm`
--> /home/ahdee/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/src/aead/gcm.rs:315:26
|
315 | || cpu::arm::PMULL.available(cpu_features)
| ^^^^^ not found in `cpu::arm`
error[E0425]: cannot find value `ARMCAP_STATIC` in this scope
--> /home/ahdee/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.20/src/cpu.rs:235:41
|

rust-sqlx: Lazy instance has previously been poisoned

I'm trying to run cargo fix on a project that uses slqx and am getting the following error:
error: proc macro panicked
--> src/twitter/domain/user.rs:54:5
|
54 | / sqlx::query!(
55 | | r#"
56 | | INSERT INTO users
57 | | (id, created_at,
... |
84 | | user["public_metrics"]["tweet_count"].as_i64(),
85 | | )
| |_____^
|
= help: message: Lazy instance has previously been poisoned
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
...for every instance of sqlx macro I have in my code. The weird thing is it used to work just fine, but for some reason doesn't anymore.
The only mention of the error on Google that I found is here, but I don't think it's relevant.
What might be wrong?

What to do about "match is not allowed in a const fn" error?

When running the command:
cargo install cargo-generate --features vendored-openssl
I am getting the following error:
error[E0658]: `match` is not allowed in a `const fn`
--> /home/pam/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/lib.rs:156:9
|
156 | / match address {
157 | | SocketAddr::V4(_) => Domain::IPV4,
158 | | SocketAddr::V6(_) => Domain::IPV6,
159 | | }
| |_________^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/49146
error[E0599]: no associated item named `MAX` found for type `usize` in the current scope
--> /home/pam/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/sys/unix.rs:680:46
|
680 | msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
| ^^^ associated item not found in `usize`
error[E0599]: no associated item named `MAX` found for type `usize` in the current scope
--> /home/pam/.cargo/registry/src/github.com-1ecc6299db9ec823/socket2-0.4.0/src/sys/unix.rs:740:46
|
740 | msg.msg_iovlen = min(bufs.len(), IovLen::MAX as usize) as IovLen;
| ^^^ associated item not found in `usize`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0599, E0658.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `socket2`.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-generate v0.6.1`, intermediate artifacts can be found at `/tmp/cargo-install7B7MDG`
Caused by:
build failed
Using Rust version 1.41.0 on Ubuntu 20.04.2 LTS. What am I missing here?
Updating Rust worked for me:
curl https://sh.rustup.rs -sSf | sh
New version 1.52.0

multiple applicable items in scope

I'm using Ubuntu 20.04.2.0-desktop-amd64 , Substrate 3.0.0
Version:
gh#ubuntu:~$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home: /home/gh/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.50.0 (cb75ad5db 2021-02-10)
And I'm using "cargo install --force subkey --git https://github.com/paritytech/substrate"
to download
But I can't download Subkey:
Compiling idna v0.1.5
error[E0034]: multiple applicable items in scope
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.20.1/src/field.rs:801:12
|
801 | if M::BITS > T::Mem::BITS {
| ^^^^ multiple `BITS` found
|
note: candidate #1 is defined in the trait `BitMemory`
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.20.1/src/mem.rs:44:2
|
44 | const BITS: u8 = mem::size_of::<Self>() as u8 * 8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `IsNumber`
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/funty-1.2.0/src/lib.rs:144:2
|
144 | const BITS: u32;
| ^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1
|
801 | if BitMemory::BITS > T::Mem::BITS {
| ^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #2
|
801 | if IsNumber::BITS > T::Mem::BITS {
| ^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.20.1/src/field.rs:801:19
|
765 | fn load_le<M>(&self) -> M
| - this type parameter
...
801 | if M::BITS > T::Mem::BITS {
| ^^^^^^^^^^^^ expected type parameter `M`, found `u8`
|
= note: expected type parameter `M`
found type `u8`
error[E0034]: multiple applicable items in scope
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.20.1/src/field.rs:809:12
|
809 | if M::BITS > T::Mem::BITS - shamt {
| ^^^^ multiple `BITS` found
|
note: candidate #1 is defined in the trait `BitMemory`
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.20.1/src/mem.rs:44:2
|
44 | const BITS: u8 = mem::size_of::<Self>() as u8 * 8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in the trait `IsNumber`
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/funty-1.2.0/src/lib.rs:144:2
|
144 | const BITS: u32;
| ^^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #1
|
809 | if BitMemory::BITS > T::Mem::BITS - shamt {
| ^^^^^^^^^^^^^^^
help: disambiguate the associated constant for candidate #2
|
809 | if IsNumber::BITS > T::Mem::BITS - shamt {
| ^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> /home/gh/.cargo/registry/src/github.com-1ecc6299db9ec823/bitvec-0.20.1/src/field.rs:809:19
|
765 | fn load_le<M>(&self) -> M
| - this type parameter
...
809 | if M::BITS > T::Mem::BITS - shamt {
| ^^^^^^^^^^^^^^^^^^^^ expected type parameter `M`, found `u8`
|
= note: expected type parameter `M`
found type `u8`
...(The same error as above)
error: aborting due to 60 previous errors
Some errors have detailed explanations: E0034, E0308.
For more information about an error, try `rustc --explain E0034`.
error: could not compile `bitvec`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `subkey v2.0.0 (https://github.com/paritytech/substrate#f5d2faf1)`, intermediate artifacts can be found at `/tmp/cargo-installVIcyI0`
Caused by:
build failed
At the beginning of the download,the following warning appears
warning: profile package spec `cranelift-codegen` in profile `dev` did not match any packages
warning: profile package spec `cranelift-wasm` in profile `dev` did not match any packages
warning: profile package spec `libm` in profile `dev` did not match any packages
Did you mean `libc`?
warning: profile package spec `librocksdb-sys` in profile `dev` did not match any packages
warning: profile package spec `nalgebra` in profile `dev` did not match any packages
I tried again and again, but it didn't work
Is it possible to do cargo install with the repo cargo.lock with:
cargo install --locked --force subkey --git https://github.com/paritytech/substrate
Temporary issue from an upstream care. Just do:
cargo update -p funty --precise "1.1.0"

Resources