Apple M1设备Rust工具链无法找到cargo二进制文件问题求助
Rust工具链覆盖时cargo组件不兼容问题排查
问题场景
通过仓库目录的rust-toolchain文件覆盖rustup工具链时,触发以下错误:
error: the 'cargo' binary, normally provided by the 'cargo' component, is not applicable to the '1.69.0-aarch64-apple-darwin' toolchain
当前环境信息
执行rustup show的输出:
❯ rustup show Default host: aarch64-apple-darwin rustup home: /Users/myhome/.rustup installed toolchains -------------------- stable-aarch64-apple-darwin (default) stable-x86_64-unknown-linux-gnu nightly-2022-11-04-aarch64-apple-darwin 1.67.0-aarch64-apple-darwin 1.67.0-x86_64-unknown-linux-gnu 1.67.1-aarch64-apple-darwin 1.68.0-aarch64-apple-darwin 1.69.0-aarch64-apple-darwin active toolchain ---------------- 1.69.0-aarch64-apple-darwin (overridden by '/Users/myhome/myrepo/rust-toolchain') rustc 1.69.0 (84c898d65 2023-04-16)
仓库中的rust-toolchain文件内容:
1.69.0
设备为Apple M1(aarch64架构)
原因分析
- 1.69.0-aarch64-apple-darwin工具链的cargo组件损坏或未正确安装,导致rustup找不到适配的cargo二进制文件。
- 可能是工具链安装过程中断、组件文件丢失,或是架构匹配异常(比如混入了x86_64版本的组件)。
解决办法
- 重新安装cargo组件
执行命令:rustup component add cargo --toolchain 1.69.0-aarch64-apple-darwin - 重装整个工具链
如果组件安装无效,直接卸载后重装:rustup uninstall 1.69.0-aarch64-apple-darwin rustup install 1.69.0-aarch64-apple-darwin - 检查rust-toolchain文件
确保文件只包含1.69.0,没有多余空格或换行,避免rustup解析出错。 - 清理缓存后重装
若以上方法都无效,先删除工具链缓存再重装:rm -rf ~/.rustup/toolchains/1.69.0-aarch64-apple-darwin rustup install 1.69.0-aarch64-apple-darwin
内容的提问来源于stack exchange,提问作者Seto
相关产品推荐
相关产品推荐

