'BPF SDK path does not exist

I'm following the Anchor docs here, but I keep getting this error...

BPF SDK path does not exist: /Users/herbie/.cargo/bin/sdk/bpf: No such file or directory (os error 2)

I ran ls -al /Users/herbie/.cargo/bin and got this output:

total 239152
drwxr-xr-x  17 herbie  staff       544 31 Jan 16:55 .
drwxr-xr-x   9 herbie  staff       288 13 Dec 11:58 ..
-rwxr-xr-x   1 herbie  staff  12574724 31 Jan 16:49 anchor
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 cargo
-rwxr-xr-x   1 herbie  staff   7578989 14 Dec 14:05 cargo-build-bpf
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 cargo-clippy
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 cargo-fmt
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 cargo-miri
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 clippy-driver
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rls
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rust-gdb
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rust-lldb
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rustc
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rustdoc
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rustfmt
-rwxr-xr-x  12 herbie  staff   8521112 31 Jan 16:55 rustup

Haven't found much online, and have never heard of BPF before...



Solution 1:[1]

It's unclear when you're getting the error during the installation, but here's a few things to try:

For more reference, BPF is the bytecode format used by on-chain programs with Solana. You can find some more info at the links contained within https://docs.solana.com/developing/on-chain-programs/overview#berkeley-packet-filter-bpf

Solution 2:[2]

Try removing the solana cache before running your code. It worked for me. Basically, the BPF SDK hasn't been installed accurately.

rm -rf ~/.cache/solana/*

After deleting the solana cache run. It should download the BPF SDK again

solana build

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jon C
Solution 2 Damsara Perera