在Debian中配置Rust可按以下步骤操作:
更新系统并安装依赖
sudo apt update sudo apt install curl build-essential gcc make -y
安装Rustup(官方工具链管理器)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
安装过程中可选择默认配置(自动配置环境变量)。
手动配置环境变量(若安装时未自动配置)
echo 'export RUSTUP_HOME=$HOME/.rustup' | sudo tee -a /etc/profile.d/rust.sh echo 'export PATH=$PATH:$HOME/.cargo/bin' | sudo tee -a /etc/profile.d/rust.sh source /etc/profile
验证安装
rustc --version # 查看Rust编译器版本 cargo --version # 查看包管理器版本
更新Rust版本
rustup update
使用Cargo管理项目
cargo new 项目名
cargo build
cargo run
(可选)安装额外工具
如代码格式化工具rustfmt
:
rustup component add rustfmt
以上步骤参考自Rust官方文档及社区教程,确保在Debian系统上正确配置Rust开发环境。