在 Debian 上装 Rust,主要有几种方式,各有注意点。下面按推荐程度和常见坑来说。
Debian 仓库里的 rustc / cargo:
✅ 强烈建议用 rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
然后:
source "$HOME/.cargo/env"
或重新打开终端。
stable 工具链rustup update
Rust 编译 C 依赖(如 openssl、sqlite)时需要:
sudo apt update
sudo apt install -y build-essential pkg-config libssl-dev
常见缺的库:
libssl-dev(HTTPS / TLS)pkg-configclang / libclang-dev(bindgen 类库)在树莓派、香橙派等非 x86 设备:
rustup default stable-gnu
rustup toolchain install stable --profile minimal
如果你想“系统全局”:
sudo apt install cargo rustc
⚠️ 但:
source "$HOME/.cargo/env"
或把下面加到 .bashrc / .zshrc:
export PATH="$HOME/.cargo/bin:$PATH"
cargo build --release 很正常export CARGO_BUILD_JOBS=4
libcDebian 装 Rust:别用 apt,用 rustup,先装 build-essential 和 libssl-dev。
如果你告诉我:
我可以给你更精确的建议。