When getting set up with Solana development you may run into this unhelpful error message:
$ npm run build:program-rust > helloworld@0.0.1 build:program-rust > cargo build-bpf --manifest-path=./src/program-rust/Cargo.toml --bpf-out-dir=dist/program BPF SDK: /Users/matt/.local/share/solana/install/releases/1.8.6/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 error: no such subcommand: `+bpf` Did you mean `b`?
The solution for me was to completely uninstall Rust:
$ rustup self uninstall
Even after doing this I still had a version of rust installed on my system, which may have been the cause of the error in the first place:
$ which rustc /usr/local/bin/rustc
I uninstalled it with brew:
$ brew uninstall rust Uninstalling /usr/local/Cellar/rust/1.56.1... (30,734 files, 763.2MB) $ which rustc rustc not found
And then finally re-installed Rust using rustup:
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
And then compiling the rust program worked without any issues:
$ npm run build:program-rust > helloworld@0.0.1 build:program-rust > cargo build-bpf --manifest-path=./src/program-rust/Cargo.toml --bpf-out-dir=dist/program BPF SDK: /Users/matt/.local/share/solana/install/releases/1.8.6/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 Compiling proc-macro2 v1.0.27 Compiling unicode-xid v0.2.2 ...