以下是在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 <工具名>命令安装。