4

I've been working through this example: https://solana.com/developers/guides/getstarted/local-rust-hello-world

Build when I attempt to build using cargo build-bpf I get the following error:

error: package `solana-program v1.18.9` cannot be built because it requires rustc 1.75.0 or newer, while the currently active rustc version is 1.72.0-dev
Either upgrade to rustc 1.75.0 or newer, or use
cargo update -p [email protected] --precise ver
where `ver` is the latest version of `solana-program` supporting rustc 1.72.0-dev

Cargo.toml:

[package]
name = "hello_world"
version = "0.1.0"
edition = "2021"


# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
solana-program = "1.18.9"
solana-sdk = "1.18.9"

And:

rustc --version
rustc 1.77.1 (7cf61ebde 2024-03-27)
rustup --version
rustup 1.27.0 (bbb9276d2 2024-03-08)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.77.1 (7cf61ebde 2024-03-27)`
cargo --version
cargo 1.77.1 (e52e36006 2024-03-26)
cargo-build-sbf --version
solana-cargo-build-sbf 1.18.1
platform-tools v1.39
rustc 1.72.0

I just got my environment setup and not sure what I'm missing..

6 Answers 6

3

Please modify your Cargo.toml dependencies:

[dependencies]
...
solana-program = "=1.18.2"

solana-program 1.18.2 is compatible with your Rust version.

Hint: To find out which Rust version is used by anchor, run cargo-build-sbf --version.

1
  • I changed the version as you suggested and Gott the same error. Also cargo-build-sbf --version solana-cargo-build-sbf 1.18.1 platform-tools v1.39 rustc 1.72.0 Commented Apr 3 at 6:21
2

Be sure to upgrade to the newest CLI tools as well by running:

solana-install init 1.18.9

That will give you a newer Rust compiler for Solana programs:

$ solana --version
solana-cli 1.18.9 (src:9a7dd9ca; feat:3469865029, client:SolanaLabs)
$ cargo build-sbf --version
solana-cargo-build-sbf 1.18.9
platform-tools v1.41
rustc 1.75.0
2
  • cargo build-sbf --version seems stuck at previous version. Any cache I need to remove?
    – Ohad Dahan
    Commented Apr 10 at 17:18
  • 1
    Maybe, you can check for the cached platform tools in ls ~/.cache/solana/
    – Jon C
    Commented Apr 11 at 18:06
0

Upgraded Solana library and this resolved the error.

0

This worked for me.

solana-install update
0

This command worked for me:

solana-install init 1.18.9
0

If you're on macos, make sure your rust is downloaded natively and not from homebrew!

Don't doubt it's the version of solana-install, go to https://crates.io/crates/solana-install/versions and check the latest version, for example it's currently 1.18.18, then solana-install init 1.18.18, and then it's Then you can continue to anchor build :)

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.