cargo build-sbf says solana-program requires rustc 1.79.0: platform-tools ships its own rustc, update the CLI
Symptom: with a current rustup toolchain installed, cargo build-sbf still fails:
error: package solana-program v2.1.6 cannot be built because it requires
rustc 1.79.0 or newer, while the currently active rustc version is 1.75.0-dev
Uninstalling and reinstalling rustup and the Agave/Solana CLI does not change the reported version. The -dev suffix is the clue.
Cause: cargo build-sbf does not use your rustup default. The Solana/Agave CLI installs a platform-tools bundle containing its own pinned rustc (registered as the solana toolchain) and builds the SBF target with that. You cannot bump that rustc independently — its version is a property of the platform-tools release, which is a property of the installed CLI version. So a solana-program crate newer than your CLI's toolchain is unbuildable until the CLI moves.
Fixes, in order:
1. Check for a rust-toolchain.toml in the project pinning an old version — that overrides everything else and is the cheapest thing to rule out.
2. Update the CLI so a newer platform-tools rustc is installed: agave-install init <version> for 2.0 and later, or solana-install init <version> for 1.18.20 and earlier.
3. Some cargo build-sbf versions accept --tools-version to select a platform-tools release explicitly.
Pinning solana-program back to 1.18 does compile, but it locks the program to an old SDK and is not a fix.
Non-obvious part: the message names rustc, so the instinct is rustup update or rustup override, neither of which touches the toolchain actually in use. The mapping is CLI version → platform-tools → rustc, and the only supported lever is the first link.
Source: adapted from a Stack Exchange answer by Whiteseal (question by Solandy), https://solana.stackexchange.com/questions/18442/rust-toolchains-and-how-to-update-them — CC BY-SA 4.0
Two corrections, from source plus one local test. (1) Fix #1 doesn't apply. cargo-build-sbf runs 'cargo +solana build' (solana-labs v1.18.26 main.rs ~L700), and agave v3.0.6 pushes a generated '+<toolchain>' argument unless you pass --no-rustup-override. With rustup 1.29.2 and a rust-toolchain.toml pinning 1.84 in the dir, 'cargo --version' gave 1.84.1 but 'cargo +stable --version' gave 1.99.1. The +toolchain shorthand beats rust-toolchain.toml, so the file can't cause or fix this error. (2) Updating the CLI isn't the only lever. --tools-version exists in cargo-build-sbf 1.17.34, 1.18.26 and 3.0.6. 1.18.26 defaults to platform-tools v1.41, and per the platform-tools release notes v1.41/v1.42 are Rust 1.75.0 (the '1.75.0-dev' in the error), v1.43-v1.46 are Rust 1.79.0, v1.47 and v1.51 are 1.84.1, and v1.54+ are 1.89. So 'cargo build-sbf --tools-version v1.43' targets exactly the 1.79 requirement. I didn't run an old CLI against a newer platform-tools, so upgrading the CLI remains the safer default.