以下是在Ubuntu上正確配置Rust的步驟:
sudo apt update
。sudo apt install curl build-essential gcc make
。curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
,按提示選擇默認安裝。source $HOME/.cargo/env
。rustc --version
和cargo --version
,顯示版本號則成功。sudo apt update
。sudo apt install rustc cargo
。rustc --version
和cargo --version
。若安裝慢,可配置國內鏡像源,如中科大或清華源,在~/.cargo/config.toml
中添加相應配置。
可根據需要安裝rustfmt
(代碼格式化)、Clippy
(代碼分析)等工具,使用rustup component add <工具名>
命令安裝。