你的问题比较简短,“Rust在Debian怎么设置”一般可以理解为 如何在 Debian 系统上安装并配置 Rust 开发环境。下面给你一套常见、推荐的做法。
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 installation (default)source "$HOME/.cargo/env"
或者重新打开终端。
rustc --version
cargo --version
rustup update
rustup self uninstall
Debian 仓库中也有 Rust,但版本通常较旧:
sudo apt install -y rustc cargo
⚠️ 不建议用于实际开发,版本落后。
rustup component add rustfmt clippy
rustfmt:代码格式化clippy:代码检查cargo new hello
cd hello
cargo run
可设置镜像(如 ustc / tuna):
export RUSTUP_DIST_SERVER=https://rsproxy.cn
export RUSTUP_UPDATE_ROOT=https://rsproxy.cn/rustup
然后再运行安装脚本。
Rust 编译某些 crate 需要 gcc:
sudo apt install -y gcc
如果你指的是 Rust 的某个具体用途(比如 Web 服务、嵌入式、WASM、系统编程),可以告诉我,我可以给你更针对性的 Debian 配置方案。