M1芯片Mac运行anchor build报错:已装要求rustc版本仍提示过时
M1 Mac下
anchor build rustc版本不匹配问题解决 问题现象
搭载M1芯片的Mac运行anchor build时提示rustc版本过时,但本地全局rustc版本已满足要求:
solana % rustc --version rustc 1.68.0.... solana % anchor build BPF SDK: .../.local/share/solana/install/releases/1.9.29/solana-release/bin/sdk/bpf cargo-build-bpf child: rustup toolchain list -v cargo-build-bpf child: cargo +bpf build --target bpfel-unknown-unknown --release error: package `anchor-attribute-constant v0.27.0` cannot be built because it requires rustc 1.60 or newer, while the currently active rustc version is 1.59.0-dev
尝试过以下命令未解决:
solana-install update sh -c "$(curl -sSfL https://release.solana.com/v1.9.13/install)" solana-install init 1.9.13
解决步骤
- 卸载旧版Solana
旧版Solana(1.9.x)的BPF SDK绑定的rustc版本过低,无法兼容Anchor 0.27.0,先执行卸载:
solana-install uninstall
- 安装兼容版本的Solana
Anchor 0.27.0要求Solana版本至少为1.14.16,执行对应安装命令:
sh -c "$(curl -sSfL https://release.solana.com/v1.14.16/install)"
- 更新rust工具链
确保bpf工具链版本符合要求:
rustup update rustup toolchain install bpf
- 重新运行
anchor build
回到项目目录执行:
anchor build
内容的提问来源于stack exchange,提问作者bernardo
相关产品推荐
相关产品推荐

