version
要降低 Anchor CLI 的版本,你可以通过以下步骤进行:
-
卸载当前版本:
cargo uninstall anchor-cli -
安装指定版本:
例如,安装 0.29.0 版本:
cargo install anchor-cli --version 0.29.0 -
验证安装:
确认安装的版本:
anchor --version
如果你需要其他版本,替换 0.29.0 为所需的版本号即可。
记录
$ ~/Desktop/temp/solana/hello anchor build
error: package `solana-program v1.18.26` cannot be built because it requires rustc 1.75.0 or newer, while the currently active rustc version is 1.68.0-dev
Either upgrade to rustc 1.75.0 or newer, or use
cargo update -p solana-program@1.18.26 --precise ver
where `ver` is the latest version of `solana-program` supporting rustc 1.68.0-dev
$ ~/Desktop/temp/solana/hello cargo-build-sbf --version
solana-cargo-build-sbf 1.17.0
platform-tools v1.37
rustc 1.68.0
$ ~/Desktop/temp/solana/hello solana-install update
✨ Update successful to 1.17.34
$ ~/Desktop/temp/solana/hello cargo-build-sbf --version
solana-cargo-build-sbf 1.17.34
platform-tools v1.37
rustc 1.68.0
$ ~/Desktop/temp/solana/hello rustc --version
rustc 1.83.0 (90b35a623 2024-11-26)
$ ~/Desktop/temp/solana/hello rustup show
Default host: aarch64-apple-darwin
rustup home: /Users/haotian.chen/.rustup
installed toolchains
--------------------
stable-aarch64-apple-darwin
1.78.0-aarch64-apple-darwin
1.79.0-aarch64-apple-darwin
1.80.1-aarch64-apple-darwin
1.81.0-aarch64-apple-darwin (default)
1.63-aarch64-apple-darwin
solana
active toolchain
----------------
stable-aarch64-apple-darwin (directory override for '/Users/haotian.chen/Desktop/temp/solana/hello')
rustc 1.83.0 (90b35a623 2024-11-26)
记录2
$ ~/Desktop/temp/solana/hello solana --version
solana-cli 1.17.34 (src:b04a806c; feat:3746964731, client:SolanaLabs)
$ ~/Desktop/temp/solana/hello solana-install init 1.18.9
✨ 1.18.9 initialized
$ ~/Desktop/temp/solana/hello solana --version
solana-cli 1.18.9 (src:9a7dd9ca; feat:3469865029, client:SolanaLabs)
$ ~/Desktop/temp/solana/hello cargo build-sbf --version
solana-cargo-build-sbf 1.18.9
platform-tools v1.41
rustc 1.75.0
$ ~/Desktop/temp/solana/hello
