使用 Anchor 框架重新创建 web3 应用程序时,没有这样的命令:`+solana`

问题描述 投票:0回答:1

我正在尝试使用 Rust 中的 Solana Anchor 框架创建一个 web3 应用程序。我通过

创建了项目
$ anchor init hello-world
$ cd ./hello-world

现在,每当我尝试跑步时:

$ anchor build
OR
$ anchor test

我收到此错误:

error: no such command: `+solana`

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

我是 Solana、Rust 和 Anchor 的新手。我无法弄清楚我错过了什么。以下是我目前使用的版本:

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
rust rust-cargo solana anchor-solana
1个回答
0
投票

我还没有遇到过这个问题,但我想这与 rustc 和 solana 的版本兼容性有关。 我目前使用 rustc 1.69.0、cargo 1.69.0 和 solana-cli 1.16.14

因此,如果您使用更新后的 rustc 和 Cargo,请尝试使用更新后的 solana-cli,即 v1.16.14 https://github.com/solana-labs/solana/releases/tag/v1.16.14

如果这不起作用,请尝试将 rustc 和 Cargo 降级到 v1.69.0。如果还是不行,那就不是版本兼容性问题了。但我认为这应该很可能解决问题。

让我知道结果。

© www.soinside.com 2019 - 2024. All rights reserved.