安装Rust时--target参数报错,求打包服务器rustc替代安装方案
Rust安装报错的解决及替代方案
问题根源
你的安装命令里重复传递了目标平台参数:同时使用了-t(--target的短选项)和--target,rustup脚本更新后参数校验逻辑变严格,因此触发了a value is required for '--target <targets>...' but none was supplied错误。
修正原命令
去掉重复的参数即可正常执行,以下两种写法任选其一:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=default --target x86_64-apple-darwin --no-modify-path
或者使用短选项格式:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=default -t x86_64-apple-darwin --no-modify-path
其他可行安装方法
离线安装包方式
- 下载对应x86_64-apple-darwin平台的rustup-init二进制文件
- 赋予执行权限:
chmod +x rustup-init-x86_64-apple-darwin - 执行安装并指定参数:
./rustup-init-x86_64-apple-darwin -y --profile=default --target x86_64-apple-darwin --no-modify-path
手动部署rustc和cargo
- 下载对应平台的rustc、cargo二进制压缩包
- 解压到自定义目录(如
/usr/local/rust) - 若无需修改系统PATH,可直接通过绝对路径调用工具(如
/usr/local/rust/bin/rustc);若需要全局调用,将解压后的bin目录添加到系统PATH即可。
内容的提问来源于stack exchange,提问作者mqliutie
相关产品推荐
相关产品推荐

