在Debian上搭建Rust開發環境,可以按照以下步驟進行:
sudo apt update
sudo apt install git curl build-essential
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y --profile minimal
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
rustc --version
cargo --version
為了加快下載速度,可以配置國內鏡像源,例如清華源:
.cargo/config.toml
文件:mkdir -p ~/.cargo
nano ~/.cargo/config.toml
[source.crates-io]
replace-with = 'tuna'
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
為了更方便地進行Rust開發,可以安裝一些有用的工具:
rustup component add rustfmt
rustup component add clippy
cargo new hello_world
cd hello_world
cargo build
cargo run
如果一切順利,你應該能夠在終端中看到“Hello, world!”的輸出。
通過以上步驟,你就可以在Debian上成功搭建一個Rust開發環境。如果有任何問題,可以參考Rust官方文檔或相關社區資源。