我在使用 Rust 构建 Solana CLI 1.18.7 时遇到了问题
如果我运行“cargo build-sbf” 出现错误
error: package bumpalo v3.15.4 cannot be built because it requires rustc 1.73.0 or newer, while the currently active rustc version is 1.72.0-dev Either upgrade to rustc 1.73.0 or newer, or use cargo update -p [email protected] --precise ver where ver is the latest version of bumpalo supporting rustc 1.72.0-dev
当我运行“rustup -V”时,它假定当前活动的 rustc 版本为 1.72.0-dev
rustup 1.27.0 (bbb9276d2 2024-03-08) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active rustc version is rustc 1.76.0 (07dca489a 2024-02-04)
当我运行“rustc -V”时,情况是一样的,当前活动的 rustc 版本是 1.76.0。 当我降级 Solana CLI 时,错误包 bubblealo 检测到 rustc 活动版本为 1.68.0。
怎么会发生这种事?那我该如何继续构建 Solana
存储库可能有一个
rust-toolchain.toml
文件,用于固定编译器版本,因此为什么 rustup/rustc/cargo --version
在不同目录中报告不同的活动工具链版本。
如果您通过 rustup 安装了 rust(似乎是这种情况),您可以在 CLI 上指定工具链覆盖,如下所示:
cargo +<TOOLCHAIN> <COMMAND>
,在您的情况下,请尝试 cargo +stable build-sbf
。或者,您可以设置 RUSTUP_TOOLCHAIN
环境变量,例如,如果您正在编写 CI 脚本,这可能会更方便。
所有这些都在 Rust 的官方文档中得到了详细记录。