为什么“anchor build”和“Cargo build-bpf”显示错误的rustc版本?

3

我正在尝试使用 anchor build 构建 (https://github.com/betterclever/solend-anchor) 包,但是出现了以下错误。

error: package `uint v0.9.3` cannot be built because it requires rustc 1.56.1 or newer, while the currently active rustc version is 1.56.0-dev

我更新了 rustc ,运行命令 rustup default nightly 后出现以下信息:

info: using existing install for 'nightly-x86_64-apple-darwin'
info: default toolchain set to 'nightly-x86_64-apple-darwin'

  nightly-x86_64-apple-darwin unchanged - rustc 1.61.0-nightly 

这里显示已安装和正在使用的 rustc 版本为 1.61,然而 Anchor Build 却无法找到它。我尝试运行 cargo build-bpf,但出现了相同的问题。cargo build 看起来正常工作。 运行 anchor build 和 cargo build-bpf 出现问题的原因是什么呢?

2个回答

4

anchor buildcargo build-bpf 使用的编译器不同于系统中包含的普通 rustc 编译器,因此它们报告不同的版本是正常的。BPF 编译器随 Solana 工具套件提供。

如果您已经在计算机上安装了 Solana 工具,那么可以简单地运行以下命令:

solana-install init 1.9.13

如果您没有安装,可以运行:

sh -c "$(curl -sSfL https://release.solana.com/v1.9.13/install)"

这将为您提供所有最新的工具,包括BPF编译器。


3

我有 Solana 的最新版本,在编译下载的程序时遇到了同样的错误。

命令:

solana-install update

对我很有帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接