在 Debian 上安装 Rust 环境,最推荐、也是最官方的方式是使用 rustup。下面给你几种常见做法。
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl build-essential gcc make
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装过程中会让你选择:
1) Proceed with standard installation(默认,推荐)2) Customize installation3) Cancel installation直接回车选 1 即可。
source "$HOME/.cargo/env"
或重新打开终端。
rustc --version
cargo --version
Debian 仓库里的 Rust 版本通常较旧:
sudo apt install -y rustc cargo
查看版本:
rustc --version
⚠️ 如果你要用最新特性或第三方库,建议用 rustup。
rustup update
rustup self uninstall
rustup install stable
rustup install nightly
rustup default stable
cargo new hello
cd hello
cargo run
如果你是用于 开发、嵌入式、WebAssembly、Linux 服务 等场景,我也可以给你更具体的环境配置建议。