在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编程语言。如果遇到任何问题,请检查网络连接是否正常,并确保所有命令都正确执行。