Unable to run cargo build on hello-contract

I just try to run hello-world contract and getting below error .
any one have any suggestion,how to resolve it .
I have already remove the cache and remove the package and try again but still same error.

cargo build
error: failed to download zeroize v1.4.1

Caused by:
unable to get packages from source

Caused by:
failed to parse manifest at /home/aditya/.cargo/registry/src/github.com-1ecc6299db9ec823/zeroize-1.4.1/Cargo.toml

Caused by:
feature resolver is required

consider adding cargo-features = ["resolver"] to the manifest

1 Like
Caused by:
feature resolver is required

Sounds like you've run into this issue:

You are probably using an older version of cargo than what the zeroize crate supports.

Your version of Rust is too old. You need to upgrade your Rust. If you've installed it via Rustup as recommended, then run:

rustup update

If you've installed Rust from some other source, like a Linux distro or other package manager, uninstall Rust, and then install it from https://rustup.rs

1 Like

What version you are looking for ? rust --version
rustup 1.24.3 (ce5817a94 2021-05-31)

rustup (1.24) version is not relevant - one rustup version works with all rustc versions. The important one is rustc version, which needs to be 1.52 or later.

rustc --version
rustc 1.53.0 (53cb7b09b 2021-06-17)
rustup --version
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.53.0 (53cb7b09b 2021-06-17)`

I am facing the same issue on my M1 mac. Were you able to solve it?

The solution is the same for all platforms: run rustup update.

If you don't have rustup, because you've installed Rust from another source (like Homebrew), uninstall it first, and then install from https://rustup.rs.

I tried the same. Did not work for me.

Here's the current versions on my system:

rustc --version
rustc 1.54.0 (a178d0322 2021-07-26)

cargo --version
cargo 1.54.0 (5ae8d74b3 2021-06-22)

rustup --version
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.54.0 (a178d0322 2021-07-26)

What project are you building? If it's the casper-ecosystem/hello-world contract, the problem is that it has a rust-toolchain file, which makes it use an old development snapshot of the Rust compiler, but it doesn't have a Cargo.lock file specifying versions of its dependencies that work with that old compiler.

This was reported to the developers here: Braking the build cargo

You can work around this issue by running this command inside your hello-world directory:

cargo update --package zeroize --precise 1.3.0
2 Likes

I'm trying to perform

anchor test

on a sample anchor project. That's where I am facing the issue.

It looks like this was reported to anchor here. A similar fix was added here but later reverted after solana updated to a newer Rust toolchain here.

I'm not familiar with the anchor build system, so I'm not sure what action users need to take in order to apply these fixes.

If you can find where the Cargo.lock file is created, you can try running the cargo update command from my previous comment in that directory, as a workaround.

1 Like

The workaround worked well! Thanks :slight_smile: However, should I be worried about any issues that might occur in the future due to version mismatches?

I don't know enough about anchor to give specific advice, but if they are still pinning the Rust toolchain to a specific version, then they should consider keeping Cargo.lock files in version control if possible, so they don't accidentally end up with dependencies that need newer toolchains. Otherwise, yes, similar issues could occur again.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.