在 Debian 上安装 Rust 工具链(编译器 rustc、包管理器 cargo 等)有几种常见方式。下面按推荐程度由高到低说明。
rustup这是 Rust 官方推荐方式,能方便地安装、升级、切换版本。
sudo apt update
sudo apt install -y curl build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
1) Proceed with standard installationsource "$HOME/.cargo/env"
rustc --version
cargo --version
rustup update
适合只偶尔运行 Rust 程序的人。
sudo apt update
sudo apt install -y rustc cargo
⚠️ 注意:
如果你是服务器 / CI:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup component add rustfmt clippy
rustup target add x86_64-pc-windows-gnu
rustup self uninstall
如果你愿意,可以告诉我:
我可以给你更精确的建议。