Debian 配置 Rust 开发工具
一 安装与初始化
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shsource "$HOME/.cargo/env"rustc --version、cargo --versionsudo apt update && sudo apt install rustc cargorustc --version、cargo --version二 选择与切换工具链
rustup install stable && rustup default stablerustup install betarustup install nightlyecho "stable" > rust-toolchain.toml三 常用组件与 IDE 配置
rustup component add rustfmtrustup component add clippyrustup component add rust-src rust-analysis四 Cargo 与构建配置
cargo new my_lib --libcargo new my_appcargo buildcargo runcargo testcargo update[source.crates-io]
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
[build]
rustflags = ["-C", "target-cpu=native"]
export RUST_BACKTRACE=1rustup target add armv7-unknown-linux-gnueabihfcargo build --target armv7-unknown-linux-gnueabihf五 系统依赖与常见问题
sudo apt install build-essential gdbecho 'source "$HOME/.cargo/env"' >> ~/.bashrc(或 ~/.zshrc),然后 source 相应文件。echo 'export RUSTUP_HOME=/opt/rust' | sudo tee -a /etc/profile.d/rust.sh
echo 'export PATH=$PATH:/opt/rust/bin' | sudo tee -a /etc/profile.d/rust.sh
source /etc/profile
rustup update(保持工具链与组件为最新稳定版)。