在 Ubuntu 上配置 Rust,版本选择通常取决于你的使用场景。下面给你一个清晰的建议:
Rust 有三种主要发布渠道:
选择:Stable(稳定版)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装后默认就是 stable。
选择:Stable + 特定工具链
例如:
rustup target add x86_64-unknown-linux-gnu选择:Nightly
仅在你明确需要时才用,例如:
async fn 早期特性rustc 内部 APIrustup toolchain install nightly
rustup default nightly
# 不推荐
sudo apt install rustc
# 安装 rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# 使用 stable
rustup default stable
# 常用组件
rustup component add rustfmt clippy
# rust-toolchain.toml
[toolchain]
channel = "1.78.0"
这样团队成员和 CI 都用同一版本。
Ubuntu 上写 Rust,直接用 Stable + rustup,不要用 apt 的版本。
如果你是:
rust-toolchain.toml如果你愿意,可以告诉我:
我可以给你更精确的配置方案。