温馨提示×

debian配rust要几步

小樊
39
2026-10-16 20:44:51
栏目: 编程语言

在 Debian 上配置 Rust 环境,通常只需要 3 步(不含可选步骤):

1️⃣ 更新系统并安装依赖

sudo apt update
sudo apt install -y curl build-essential

2️⃣ 使用官方脚本安装 Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

安装时一般选 1) Proceed with installation (default)

3️⃣ 使环境变量生效

source "$HOME/.cargo/env"

✅ 验证是否成功:

rustc --version
cargo --version

(可选)第 4 步:配置国内镜像(加速)

mkdir -p ~/.cargo
cat >> ~/.cargo/config.toml <<'EOF'
[source.crates-io]
replace-with = "rsproxy"

[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"

[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
EOF

总结

  • 最少 3 步即可在 Debian 上配好 Rust
  • 推荐用 rustup,方便管理版本和工具链

如果你是要 Debian 服务器 / WSL / 树莓派 / 交叉编译,我也可以给你更具体的方案。

0 踩