When I run anchor build or anchor test:

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

But checking rustc returns:

% rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)

How can I fix the error? Why is anchor not using the rustc I have installed?

  • I ran into a similar issue bc I had done rustup update but didn't follow up with rustup default <version number> and so it hadn't actually switched over. What do you get when you run rustc --version?
    – gxc
    Commented Jul 9, 2023 at 17:19
  • rustc 1.70.0 (90c541806 2023-05-31) Commented Jul 10, 2023 at 14:26
  • Be sure to update your Solana build tools by running solana-install init 1.16.3
    – Jon C
    Commented Jul 11, 2023 at 10:37
  • Similar problem here. ---------- error: package toml_edit v0.21.1 cannot be built because it requires rustc 1.69 or newer, while the currently active rustc version is 1.68.0-dev Either upgrade to rustc 1.69 or newer, or use cargo update -p [email protected] --precise ver where ver is the latest version of toml_edit supporting rustc 1.68.0-dev ---------- How can I fix the error? I'm using anchor 0.29.0, solana-cli 1.17.7
    – Julbh
    Commented Mar 1 at 0:47

5 Answers 5


Had this same issue with solana-program v1.16.5 and rustc 1.71.0 (8ede3aae2 2023-07-12).

No idea what the correct way to resolve this would be but downgrading to solana-program v1.16.3 worked for me.

So basically only thing I did is instead of running solana-install update which updates to the latest stable version I just ran solana-install init 1.16.3 and things started to work.

  • 1
    This answer works but the other one - where you update your Solana Tools instead of downgrading - is better.
    – mikemaccana
    Commented Feb 8 at 20:38
  • In my case, anchor init was generating a Cargo.lock file with 1.18.9. So I said "solana init 1.18.9" and things started working.
    – blispr
    Commented Apr 2 at 9:02

When you use anchor build, or cargo build-sbf or cargo build-bpf (which is deprecated) it uses rustc installed with Solana tools. To check the version of rustc from Solana Tools, run:

cargo-build-sbf --version

To fix the error you need to get latest (or newer enough for your program dependencies) Solana tools. Run the following command to upgrade your Solana tools:

$ solana-install init 1.16.15

You may want to replace "1.16.15" with the latest available version or required version (see your error message).


use rustup to select the correct version - to compile onto solana correctly you need to match the runtime of the target environment (devnet,testnet,mainnet-beta)

A lot of Solana rust deps are also locked to 1.62.3 - if you upgrade past this then you will get module based issues

To fix mod issues add this constraint to Anchor.toml solana-program = "=1.14.20"


I had the same problem. When I checked cargo-build-sbf --version it seemed to be older versions.
I got result
solana-cargo-build-sbf 1.17.25
platform-tools v1.37
rustc 1.68.0

After I used sh -c "$(curl -sSfL https://release.solana.com/v1.18.8/install)" to update to Solana version 1.18.8 I ran cargo-build-sbf --version again
with result
solana-cargo-build-sbf 1.18.8
platform-tools v1.41

RustC was not mentioned anymore.
I installed the Rust installer again by using

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

After this the anchor test command ran without any errors

I hope this works for you too...


cargo install --force anchor-cli

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.