6

When building an onchain program with cargo build-sbf using solana-program v1.18, I get the following error:

error: package solana-program v1.18.0 cannot be built because it requires rustc 1.72.0 or newer, while the currently active rustc version is 1.68.0-dev

I'm using v1.17.17 of the CLI:

$ cargo build-sbf -V
solana-cargo-build-sbf 1.17.17
platform-tools v1.37
rustc 1.68.0
$ solana -V
solana-cli 1.17.17 (src:27a43800; feat:1337574167, client:SolanaLabs)

How can I resolve this?

(inspired by https://github.com/solana-labs/solana/issues/34987)

1 Answer 1

7

You have a few options to fix the build:

Use a command line argument to specify a version of the build tools

As of cargo build-sbf that comes bundled with Solana v1.16, you can use the --tools-version argument to use a different version of the build tools. Version 1.39 of the build tools contains a Rust compiler at 1.72, so you can run:

cargo build-sbf --tools-version v1.39

Upgrade to Solana tools 1.18

Upgrade to the Solana 1.18 tools, which defaults to v1.39 of the build tools:

solana-install init 1.18.0

Note at the time of writing Anchor was not ready for 1.18.

Set your solana-program version

As a last ditch effort, you can set your build to use v1.17 of solana-program by specifying the version in your Cargo.toml:

cargo add solana-program@"=1.17"

This is recommended by Solana Rust getting started Guide.

If you intend to publish your program crate, it will be much harder for others to use, forcing them onto exactly one version of solana-program. If any other crate in the build does the same thing, then it will be impossible to 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.