Rust Tools
Sources:
- --> How To Install Rust on Ubuntu 20.04
Install
Run the command to download the
rustuptool and install the latest stable version of Rust:1
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
Next, run the following command to add the Rust toolchain directory to the PATH environment variable:
1
source $HOME/.cargo/env
Verify the Rust installation by requesting the version:
1
rustc --version
Installing a Compiler
Rust requires a linker program to join compiled outputs into one file. The GNU Compiler Collection (
gcc) in thebuild-essentialpackage includes a linker. If you don’t installgcc, you need to useaptto install thebuild-essentialpackage.First, update the Apt package index:
1
sudo apt update
Next, upgrade any out-of-date packages:
1
sudo apt upgrade
When the upgrades are complete, install the
build-essentialpackage:1
sudo apt install build-essential
Now rust and corresponding tools (rustup, cargo) have been installed
Update
1 | rustup update stable |
Switch source
If you're in China, you need to download from a mirror site instead of the original site.
There're various mirrors like USTC mirror, tuna mirror, etc. Remember to compare their speed before choosing. Sometimes ustc mirror can be very slow and sometimes tuna mirrir can be very slow.
1 | mkdir -p ~/.cargo |
Write:
1 | [source.crates-io] |
Also, edit your ~/.bashrc or ~/.zshrc:
1 | # Add following: |