I keep getting this error when i run anchor build:

error: no such command: +solana

    Cargo does not handle `+toolchain` directives.
    Did you mean to invoke `cargo` through `rustup` instead?

anchor-cli 0.29.0 solana-cli 1.18.12

cargo build works, but anchor build does not. Any ideas to what is causing the problem?

  • which OS are you using? How did you install solana? using the installation script?
    – Jimii
    Commented May 3 at 19:42
  • Be sure to avoid using brew for installing anything. Install rust with rustup and solana with the installation script, and remove any packages installed with brew
    – Jon C
    Commented May 5 at 21:57

1 Answer 1


I'm answering my own question: it looks like i had installed anchor 2 different ways. one was with homebrew. after i did brew uninstall, and reinstalled it with rustup, it seems to be working. i've seen this error quite often with no solution, so hopefully this helps others. delete the brew installation!

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.