在Debian上安装Rust编程语言,推荐使用rustup
工具。以下是详细的安装步骤:
更新系统:
sudo apt update
sudo apt upgrade -y
安装必要的构建工具:
sudo apt install build-essential curl gcc make -y
下载并运行rustup
安装程序:
wget -qO - https://sh.rustup.rs | sudo sh -s -- --no-modify-path -y
这个命令会将rustup
工具链下载到自定义安装目录/opt/rust
,并将RUSTUP_HOME
和CARGO_HOME
环境变量定义到该目录。
添加Rust到系统路径:
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
重新加载Shell配置文件:
source /etc/profile
验证Rust安装:
rustc --version
如果安装成功,您将看到Rust编译器的版本信息。
为Bash生成rustup
命令补全:
rustup completions bash > /usr/share/bash-completion/completions/rustup
source /etc/profile.d/bash_completion.sh
现在,您可以在Bash中输入rustup
并按Tab
键自动补全命令。
通过以上步骤,您应该能够在Debian系统上成功安装Rust编程语言。如果遇到任何问题,请检查网络连接是否正常,并确保所有命令都正确执行。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: debian系统版本如何查看