当前位置: 首页 > news >正文

CentOS7 安装 rust 1.82.0

CentOS7 安装 rust 1.82.0

我在CentOS7.9中安装rust遇到报错版本低,再升级版本的过程中遇到诸多问题,简单记录。

遇到的问题

提示版本低

centos7 安装 ERROR: Rust 1.75.0 or newer required.Rust version 1.72.1 was found.

原因是 CentOS7 的默认的软件源中的rust是1.72.1版本。下载不到1.75版本。

解决方案1–不管用

在网上找了很多个版本的rust的rpm包,但是由于CentOS7停止维护了,所以rpm包都是CentOS8和CentOS9之后的。下载了之后安装的时候会报错依赖缺失。

下载地址:
https://pkgs.org/download/rust
https://rpmfind.net/linux/rpm2html/search.php?query=rust

root@22_150:~# rpm -ivh rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64.rpm 
warning: rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID ced7258b: NOKEY
error: Failed dependencies:libLLVM-17.so()(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libLLVM-17.so(LLVM_17)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libc.so.6(GLIBC_2.18)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libc.so.6(GLIBC_2.25)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libc.so.6(GLIBC_2.27)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libc.so.6(GLIBC_2.28)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libstdc++.so.6(CXXABI_1.3.9)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64libstdc++.so.6(GLIBCXX_3.4.21)(64bit) is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64rust-std-static(x86-64) = 1.75.0-1.module_el8.10.0+3770+3cd00e1b is needed by rust-1.75.0-1.module_el8.10.0+3770+3cd00e1b.x86_64

基于这种情况,升级libc和其他的组件会导致系统崩溃,所以不能采用这种方式。

解决方案2–管用

只能采用最原始的源码编译的方式了。这一步虽然复杂,但是可以解决。

首先去github下载一个最新的源码包。我现在这个时间能看到的最新版是1.88,但是我下载1.82的版本。

下载地址:
https://forge.rust-lang.org/infra/other-installation-methods.html
https://github.com/rust-lang/rust/archive/refs/tags/1.82.0.tar.gz

解压之后会看到目录中包含一个 configure,运行

root@22_150:~/rust-1.82.0# ls
build       CODE_OF_CONDUCT.md   config.toml      COPYRIGHT   LICENSE-APACHE  Makefile     REUSE.toml      src             x
Cargo.lock  compiler             configure        INSTALL.md  LICENSE-MIT     README.md    rust-bors.toml  tests           x.ps1
Cargo.toml  config.example.toml  CONTRIBUTING.md  library     LICENSES        RELEASES.md  rustfmt.toml    triagebot.toml  x.py
root@22_150:~/rust-1.82.0# 
root@22_150:~/rust-1.82.0# 
root@22_150:~/rust-1.82.0# 
root@22_150:~/rust-1.82.0# 
root@22_150:~/rust-1.82.0# ./configure 
configure: processing command line
configure: 
configure: build.configure-args := []
configure: profile              := dist
configure: 
configure: writing `config.toml` in current directory
configure: 
configure: run `python /root/rust-1.82.0/x.py --help`

下面提示执行 python /root/rust-1.82.0/x.py --help

执行这个命令超级慢,挂了梯子就快了。

执行的过程,大概就是下载三个文件,文件位置:/root/rust-1.82.0/build/cache/2024-09-05/
我们可以手动操作者三个文件,手动安装。

https://static.rust-lang.org/dist/2024-09-05/rust-std-1.81.0-x86_64-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/2024-09-05/rust-std-1.81.0-x86_64-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/2024-09-05/rustc-1.81.0-x86_64-unknown-linux-gnu.tar.xz

每一个文件都解压,然后执行里面的 install.sh,即可。

root@22_150:~/rust-1.82.0/build/cache# cd rustc-1.81.0-x86_64-unknown-linux-gnu
root@22_150:~/rust-1.82.0/build/cache/rustc-1.81.0-x86_64-unknown-linux-gnu# ls
components  COPYRIGHT  git-commit-hash  git-commit-info  install.sh  LICENSE-APACHE  LICENSE-MIT  README.md  rustc  rust-installer-version  version
root@22_150:~/rust-1.82.0/build/cache/rustc-1.81.0-x86_64-unknown-linux-gnu# ./install.sh 
install: uninstalling component 'rustc'
install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh
install: installing component 'rustc'rustc installed.root@22_150:~/rust-1.82.0/build/cache/rustc-1.81.0-x86_64-unknown-linux-gnu# 

提示安装完。三个文件一样的操作即可。

系统重启之后就正常了。不重启也行,新开一个shell正常加载环境变量就可以了。

http://www.dtcms.com/a/295959.html

相关文章:

  • C语言转义字符‘\\‘‘ 解析与常见误区
  • 收银系统合作模式全解析:SaaS、私有化部署与开源版选型指南
  • Kylin V10 4070安装nvidia驱动+CUDA+docker安装
  • 循环队列的两种实现
  • Spring AI 系列之二十四 - ModerationModel
  • 每日算法刷题Day52:7.24:leetcode 栈5道题,用时1h35min
  • 前端性能新纪元:Rust + WebAssembly 如何在浏览器中实现10倍性能提升(以视频处理为例)
  • uniapp nvue开发App 横竖屏切换丢失上下文导致 setTimeout和clearTimeout报错
  • [网安工具] 自动化威胁检测工具 —— D 盾 · 使用手册
  • SAP-MM-采购订单批量创建 excel 版
  • 保留5位小数封装一个自定义指令
  • Linux 内核基础统简全解:Kbuild、内存分配和地址映射
  • 10分钟搭建脚手架:Spring Boot 3.2 + Vue3 前后端分离模板
  • Springboot儿童医院问诊导诊系统aqy75(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
  • 使用钉钉开源api发送钉钉工作消息
  • C语言 一文详解常用的字符串操作函数及模拟实现
  • 医疗系统国产化实录:SQL Server国产替代,乙方保命指南
  • DigitalOcean 一键模型部署,新增支持百度开源大模型ERNIE 4.5 21B
  • 集合中Comparable接口和Equals方法的冲突
  • 【Mermaid 离线工具】Mermaid 流程图生成器 - 高清PNG输出,一键生成专业级流程图!
  • 共创养生新时代——2025酵素益生产品展暨中秋滋补选品节即将开启
  • QT6 源(165)模型视图架构里的所有的信号函数概览
  • UNETR++: Delving Into Efficient and Accurate 3D Medical Image Segmentation
  • 深度分析Java内存模型
  • 【全新上线】境内 Docker 镜像状态监控
  • 算法第三十八天:动态规划part06(第九章)
  • 【shell脚本编程】day1 备份指定文件类型
  • Unreal5从入门到精通之 动画蓝图 快速入门
  • ML1-ETO 阳性白血病的复发与 LSC 的持续存在密切相关
  • 2025智能BI⼯具竞品深度解析:DataFocus如何挑Tableau与PowerBI的霸主地位?