cargo version 2021 required on Solana anchor build - rust

I am trying to run anchor build and am receiving the following response:
BPF SDK: /root/.local/share/solana/install/releases/1.8.0/solana-release/bin/sdk/bpf
Running: rustup toolchain list -v
Running: cargo +bpf build --target bpfel-unknown-unknown --release
error: failed to download `solana-frozen-abi v1.9.4`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/root/.cargo/registry/src/github.com-1ecc6299db9ec823/solana-frozen-abi-1.9.4/Cargo.toml`
Caused by:
feature `edition2021` is required
consider adding `cargo-features = ["edition2021"]` to the manifest
PS: I have already tried suggestions at: Unable to specify `edition2021` in order to use unstable packages in Rust

It looks like your solana install is quite out of date. I would install either 1.8.11 or just run solana-install update

At times, also consider downloading to like in my case I had to change from 2021 in my Cargo.toml file to 2018 and this has worked

Related

How I can fix 'failed to parse the `edition` key' in anchor build command?

I am trying run anchor build but
error: failed to download `anchor-attribute-access-control v0.26.0`
Caused by:
unable to get packages from source
Caused by:
failed to parse manifest at `/Users/???/.cargo/registry/src/github.com-1ecc6299db9ec823/anchor-attribute-access-control-0.26.0/Cargo.toml`
Caused by:
failed to parse the `edition` key
Caused by:
this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.
I fix edition but I see the same error for another packages. (for example)
Caused by:
failed to parse manifest at `/Users/???/.cargo/registry/src/github.com-1ecc6299db9ec823/anchor-attribute-account-0.26.0/Cargo.toml`
I guess I can do smth I don't need fix manually each package.
Thanks
PS:
rustup -V:
rustup 1.25.1 (bb60b1e89 2022-07-12)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.66.1 (90743e729 2023-01-10)`
cargo -V
cargo 1.66.1 (ad779e08b 2023-01-10)
anchor -V
anchor-cli 0.26.0
os: macOS Big Sur 11.6.5

Rust: substrate node template build error

I have been following these instructions:
https://substrate.dev/docs/en/knowledgebase/getting-started/
https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/setup
I get the following error after trying to run this code:
cd substrate-node-template
# NOTE: you should always use the `--release` flag
cargo build --release
# ^^ this will take a while!
This is the error, any idea what's happening?:
Downloaded approx v0.3.2
Downloaded parity-db v0.2.3
error: failed to parse manifest at /Users/ilyssaevans/.cargo/registry/src/github.com-1ecc6299db9ec823/parity-db-0.2.3/Cargo.toml
Caused by:
failed to parse the version requirement `0.11 ` for dependency `parking_lot`
Caused by:
expected comma after minor version number, found '\t'
zsh: command not found: #
run
cargo update -p parity-db
If this doesn't help please clear cargo cache and reinstall

Build fails with Error: Pear requires a 'dev' or 'nightly' version of rustc even after a successful rustup override set nightly

Windows 10
rustup 1.23.1 (3df2264a9 2020-11-30)
default rustc 1.50.0 (cb75ad5db 2021-02-10)
project rustc 1.52.0-nightly (4a8b6f708 2021-03-11)
rocket = "0.4.4"
I'm trying to build a rust project with rocket but I always get this error when compiling, even after successfully overwriting the project's toolchain:
D:\GitHub\Learning-Rust\poke_api> rustup override set nightly
info: using existing install for 'nightly-x86_64-pc-windows-msvc'
info: override toolchain for 'D:\GitHub\Learning-Rust\poke_api' set to 'nightly-x86_64-pc-windows-msvc'
nightly-x86_64-pc-windows-msvc unchanged - rustc 1.52.0-nightly (4a8b6f708 2021-03-11)
PS D:\GitHub\Learning-Rust\poke_api> cargo build
Compiling winapi v0.3.9
Compiling serde_derive v1.0.124
Compiling rocket v0.4.7
Compiling pear_codegen v0.1.4
Compiling rocket_codegen v0.4.7
Compiling proc-macro2 v1.0.24
Compiling pq-sys v0.4.6
Compiling aho-corasick v0.6.10
Compiling serde_json v1.0.64
error: failed to run custom build command for `pear_codegen v0.1.4`
Caused by:
process didn't exit successfully: `D:\GitHub\Learning-Rust\poke_api\target\debug\build\pear_codegen-e182711746033ac9\build-script-build` (exit code: 101)
--- stderr
Error: Pear requires a 'dev' or 'nightly' version of rustc.
Installed version: 1.48.0 (2020-11-16)
Minimum required: 1.31.0-nightly (2018-10-05)
thread 'main' panicked at 'Aborting compilation due to incompatible compiler.', C:\Users\gabre\.cargo\registry\src\github.com-1ecc6299db9ec823\pear_codegen-0.1.4\build.rs:24:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
I had a similar issue while using rocket. Same error message too, Error: Pear requires a 'dev' or 'nightly' version of rustc.
If you get to the get-started page on rocket framework website. It says, "Rocket makes abundant use of Rust's syntax extensions and other advanced, unstable features. Because of this, we'll need to use a nightly version of Rust."
My issue was I was not using a nightly version of rust. Running this on my terminal in my project directory did it for me.
rustup override set nightly
If you check the cargo version for that directory after,
cargo version
you will confirm it has switched to nightly version
Failed compilation even with nightly
It looks like you have some outdated dependencies (pear-codegen probably being the one that causes trouble), updating these may resolve the compilation issues.
General notes on how to override the toolchain
Using rustups override works fine, but it is bound to your local rustup configuration and not specified inside the project.
In order to achieve this, thereby making the project more portable and allowing others to always use the correct toolchain, I would recommend the toolchain file. It can look something like this (example taken from linked page) and will accurately specify the required toolchain only for the containing project.
# rust-toolchain.toml
[toolchain]
channel = "nightly-2020-07-10"
components = [ "rustfmt", "rustc-dev" ]
targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
profile = "minimal"
For your purposes a simple configuration like this will most likely be all you need, although adding the components you want to use would be beneficial.
[toolchain]
channel = "nightly"
My issue was with rust-analyser that wouldn't start because multiple rocket dependencies needed nightly or dev version of rustc.
These steps fixed my issue:
Switch to nightly for my rocket project by running rustup override set nightly inside the app folder.
Remove all target folders in my project. (I also had one in root)
Manually remove the faulty cached packages from cargo cache. cd ~/.cargo/registry/cache/github.com-xxxxxxxxxxxx && rm -r pear_codegen-0.1.5/

Unable to build bevy on windows rust

I am trying to use bevy game engine with rust on windows. I have x86_64-mingw installed on my machine.
I have setup the rust tool chain default to x86_64-pc-windows-gnu. I put bevy = "0.4.0" under my dependencies in the Cargo.toml.
I tried cargo build and I get the following error
error: failed to run custom build command for `syn v1.0.63`
Caused by:
could not execute process `C:\Users\USERNAME\Projects\rust-game\target\debug\build\syn-a158346a8e8b6be7\build-script-build` (never executed)
Caused by:
Access is denied. (os error 5)
warning: build failed, waiting for other jobs to finish...
error: build failed
When I tried to compile in administrator mode syn compiled but another lib was giving error
Compiling proc-macro2 v1.0.24
Compiling syn v1.0.63
Compiling serde_derive v1.0.124
Compiling serde v1.0.124
error: failed to run custom build command for `proc-macro2 v1.0.24`
Caused by:
could not execute process `C:\Users\USERNAME\Projects\rust-game\target\debug\build\proc-macro2-a1d2a8cf734884f9\build-script-build` (never exe
cuted)
Caused by:
Access is denied. (os error 5)
warning: build failed, waiting for other jobs to finish...
error: build failed
Edit:
My Antivirus was preventing it, and denying it access, so just turning my AV for sometime worked!
I've tried compiling a project that uses bevy = "0.4.0" and was able to build with the stable-x86_64-pc-windows-msvc toolchain but not with stable-x86_64-pc-windows-gnu.
In my case, bevy-glsl-to-spirv is the crate that failed to build. On the bevy book is specified that you must have VS build tools 2019 installed. They do not explicitly say that you must use the msvc toolchain but as they require you to install VS build tools 2019 I guess you must compile the code using stable-x86_64-pc-windows-msvc.
You can download VS build tools 2019 here.
Also make sure that you install the stable-x86_64-pc-windows-msvc toolchain:
rustup toolchain install stable-x86_64-pc-windows-msvc
Set this toolchain as the default toolchain.
rustup default stable-x86_64-pc-windows-msvc
Finally, make sure the toolchain has been installed and set as the default toolchain:
rustup toolchain list
You should see:
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc (default)
Try to cargo build and it should work like a charm.

Is it possible to download previous nightly builds?

I have downloaded the latest Rust nightly and added this dependency to Cargo.toml:
[dependencies.http]
git = "https://github.com/chris-morgan/rust-http.git"
I'm getting lots of errors for cargo build:
...
error: aborting due to 7 previous errors
...
error: aborting due to previous error
Could not compile `regex`.
I guess this is because some dependencies have not been updated to the latest rust version. Is it possible to download the nightly from yesterday or the day before?
Installed versions:
$ rustc --version
rustc 0.13.0-nightly (c89417130 2015-01-02 21:56:13 +0000)
$ cargo --version
cargo 0.0.1-pre-nightly (1a1868b 2014-12-31 21:39:41 +0000)
If you are using rustup (the currently preferred manner of installing Rust):
rustup install nightly-2016-06-03
If you want to use the standalone Rust installers, previous versions are kept. From this Reddit thread, which links to this Rust issue:
They are officially hosted.
wget https://static.rust-lang.org/dist/2014-12-08/rust-nightly-x86_64-apple-darwin.pkg
wget https://static.rust-lang.org/dist/2014-12-12/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
If you are still using rustup.sh (not .rs), you should be able to use something like:
rustup.sh --channel=nightly --date=2016-06-03

Resources