No such command: `+solana` when reate a web3 app using Anchor framework

661 views Asked by At

I am trying to create a web3 app using Anchor framework for Solana in Rust. I created project by

$ anchor init hello-world
$ cd ./hello-world

Now, whenever I am trying to run :

$ anchor build
OR
$ anchor test

I am getting this error :

error: no such command: `+solana`

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

I am new to Solana, Rust and Anchor. I am not able to figure out what I am missing. Here are the versions I am using currently :

rustc --version
rustc 1.71.0 (8ede3aae2 2023-07-12) (built from a source tarball)

rustup --version
rustup 1.26.0 (5af9b9484 2023-04-05)

cargo --version
cargo 1.71.0 (cfd3bbd8f 2023-06-08)

solana --version
solana-cli 1.16.8 (src:b19d7219; feat:3712769919, client:SolanaLabs)

anchor --version
anchor-cli 0.28.0
1

There are 1 answers

0
Tushar Sahoo On

Well I have not faced this issue but I guess it has something to do with the version compatibility of rustc and solana. I am currently using rustc 1.69.0, cargo 1.69.0 and solana-cli 1.16.14

So if you are using the updated rustc and cargo try using the updated solana-cli i.e. v1.16.14 https://github.com/solana-labs/solana/releases/tag/v1.16.14

If this doesn't work trying downgrading rustc and cargo to v1.69.0. If still it doesn't work, then it is not a version compatibility issue. But I think this should most likely solve the issue.

Let me know the results.