Search code examples
rustrust-cargosolanabpfanchor-solana

Why is "anchor build" and "Cargo build-bpf" showing wrong rustc version?


I'm trying to build the (https://github.com/betterclever/solend-anchor) package using anchor build, however I get the following error

error: package `uint v0.9.3` cannot be built because it requires rustc 1.56.1 or newer, while the currently active rustc version is 1.56.0-dev

I updated rustc and running the command rustup default nightlyshows:

info: using existing install for 'nightly-x86_64-apple-darwin'
info: default toolchain set to 'nightly-x86_64-apple-darwin'

  nightly-x86_64-apple-darwin unchanged - rustc 1.61.0-nightly 

So it shows me that the installed and active rustc version is 1.61, however anchor build is not finding that for some reason. I also tried running cargo build-bpf but the same thing kept happening. cargo buildseemed to work fine. I'm wondering what is causing the problem when running anchor build and cargo build-bpf?


Solution

  • anchor build and cargo build-bpf use a different compiler than the normal rustc compiler included in the system, so it's normal that they report a different version. The BPF compiler comes with the Solana tool suite.

    If you already have the Solana tools installed on your computer, you can simply run:

    solana-install init 1.9.13
    

    And if you don't, you can run:

    sh -c "$(curl -sSfL https://release.solana.com/v1.9.13/install)"
    

    That will give you all of the newest tools, including the BPF compiler.