在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官方文档或相关社区资源。