BPF SDK path does not exist

When I was in step 9 of the tutorial named "Solana 101arrow-up-right", I was trying to build my first smart contract. But when I use the command as the book says, I got an unexpected error:

$ yarn run solana:build:program                                                                                                       
yarn run v1.22.17
$ cargo build-bpf --manifest-path=contracts/solana/program/Cargo.toml --bpf-out-dir=dist/solana/program
BPF SDK: /Users/alice/.local/share/solana/install/releases/stable-a812f4410ee6195a3b78642f49e07dea69759240/solana-release/bin/sdk/bpf
cargo-build-bpf child: rustup toolchain list -v
cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release
    Finished release [optimized] target(s) in 0.28s
cargo-build-bpf child: /Users/alice/.local/share/solana/install/releases/stable-a812f4410ee6195a3b78642f49e07dea69759240/solana-release/bin/sdk/bpf/scripts/strip.sh /Users/alice/Codes/Private/learn-web3-dapp/contracts/solana/program/target/bpfel-unknown-unknown/release/helloworld.so /Users/alice/Codes/Private/learn-web3-dapp/dist/solana/program/helloworld.so
Failed to execute /Users/alice/.local/share/solana/install/releases/stable-a812f4410ee6195a3b78642f49e07dea69759240/solana-release/bin/sdk/bpf/scripts/strip.sh: No such file or directory (os error 2)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

We all know this is not about yarn itself, so I google and google and google...

Most of the solutions are similar, the first solution is cargo build-bpf failsarrow-up-right, after I tried the answer which has the most thumbs-ups, I got another error which means not work:

$ yarn run solana:build:program                                                                              
yarn run v1.22.17
$ cargo build-bpf --manifest-path=contracts/solana/program/Cargo.toml --bpf-out-dir=dist/solana/program
BPF SDK path does not exist: /Users/alice/.local/share/solana/install/active_release/bin/sdk/bpf: No such file or directory (os error 2)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.l

After careful comparison, I found my situation may differ from the above question. So I keep searching and I found another question on StackOverflow with the same keyword "BPF SDK path does not existarrow-up-right". In the solution, it told me to up the version of Rust to date and check the version of Solana CLI, so I tried the following:

I updated the Rust and reinstall the Solana CLI with an exact version, and after that, I tried the build command again:

Wow! It works! I think maybe the previous version of Solana CLI I installed is somehow broken or not suitable for the Rust version. I'm relieved to finally be able to compile the program.

Last updated