Rust Install
To install Rust, follow these steps for your operating system. The easiest and most recommended way to install
Rust is using rustup
, a toolchain installer for the Rust programming language.
Installing Rust with Rustup
Step 1: Install Rustup
Open a terminal and run the following command:
shcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
This command will download and run the Rustup installation script. Follow the on-screen instructions to complete the installation. By default, Rustup installs Rust and Cargo (Rust's package manager) in your home directory.
Step 2: Configure Your Current Shell
After the installation is complete, configure your current shell to have access to the cargo
and
rustc
commands. Run:
shsource $HOME/.cargo/env
Verifying the Installation
To verify that Rust is installed correctly, run:
shrustc --version
This command should output the version of the Rust compiler installed on your system.
Updating Rust
To update Rust to the latest version, use Rustup:
shrustup update
Uninstalling Rust
If you need to uninstall Rust and Rustup, run:
shrustup self uninstall
Detailed Instructions for Different Operating Systems
Windows
- Download and run the Rust installer.
- Follow the on-screen instructions to complete the installation.
macOS
Open a terminal and run the Rustup installation script:
shcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the on-screen instructions to complete the installation.
Linux
Open a terminal and run the Rustup installation script:
shcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the on-screen instructions to complete the installation.
Using Rust in Your Project
Once Rust is installed, you can start a new project using Cargo, the Rust package manager:
shcargo new my_project
cd my_project
cargo build
cargo run
These commands will create a new Rust project, build it, and run it.