搭建Anchor首个项目时遭遇rustc版本不兼容错误求助
解决Solana环境中rustc版本与bytemuck_derive不兼容问题
错误信息
error: rustc 1.79.0-dev is not supported by the following package:
Note that this is the rustc version that ships with Solana tools and not your system's rustc version. Use `solana-install update` or head over to https://docs.solanalabs.com/cli/install to install a newer version.bytemuck_derive@1.9.2 requires rustc 1.84
Either upgrade rustc or select compatible dependency versions withcargo update <name>@<current-ver> --precise <compatible-ver>
where<compatible-ver>is the latest version supporting rustc 1.79.0-dev
解决方案
方案1:升级Solana附带的rustc版本
- 执行命令更新Solana工具链:
该命令会同步更新Solana CLI及其内置的rustc版本,使其满足solana-install updatebytemuck_derive@1.9.2对rustc 1.84的要求。 - 若更新后问题仍存在,可尝试重新安装Solana CLI,确保获取完整的最新环境。
方案2:降级bytemuck_derive到兼容版本
- 先确认支持rustc 1.79.0-dev的
bytemuck_derive最新版本(例如1.5.x系列版本通常兼容旧版rustc)。 - 执行命令锁定兼容版本:
cargo update bytemuck_derive@1.9.2 --precise 1.5.0 - 或直接在
Cargo.toml中手动指定版本:
之后执行bytemuck_derive = "=1.5.0"cargo build重新编译项目。
内容的提问来源于stack exchange,提问作者Aditya
相关产品推荐
相关产品推荐

