Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Install Rust

Rust is the programming language we will use to build our Weather Application.

  • Install Rust using the official installer
  • Verify that the installation works
  • Understand what Cargo is
  • Confirm your development environment is ready

What Is Rust?

Rust is a modern systems programming language focused on:

  • Performance
  • Memory safety
  • Concurrency
  • Reliability

Rust is widely used for:

  • Command-line tools
  • Backend services
  • WebAssembly
  • Desktop applications (including GTK apps)

We will use Rust together with GTK4 and Libadwaita to build a graphical application.

Step 1 - Install Rust Using rustup

Rust is installed using rustup, the official Rust toolchain installer.

Run the following command:

curl https://sh.rustup.rs -sSf | sh

You will see a message explaining installation options.

When prompted, select:

1) Proceed with installation (default)

Press Enter.

The installer will:

  • Download the Rust compiler
  • Install Cargo (Rust’s package manager)
  • Configure your environment

This may take a few minutes.

Step 2 - Configure Your Environment

After installation completes, you may see a message like:

To get started you may need to restart your current shell.

Run:

source $HOME/.cargo/env

This ensures the Rust tools are available in your terminal session.

Step 3 - Verify Installation

Check that Rust and Cargo is installed correctly:

rustc --version
cargo --version

If both commands work, Rust is installed successfully.

What Is Cargo?

Cargo is Rust’s:

  • Build system
  • Package manager
  • Dependency manager
  • Project generator

You will use Cargo to:

  • Create new projects
  • Add dependencies
  • Compile your application
  • Run your application

Think of Cargo as the central tool for Rust development.

To confirm everything works, create a simple test project:

cargo new rust_test
cd rust_test
cargo run

You should see:

Hello, world!
cd ..
rm -rf rust_test

Common Issues and Solutions

Command Not Found: rustc or cargo

If you see:

command not found: rustc

Run:

source $HOME/.cargo/env

If the issue persists, restart your terminal.

curl Not Found

If curl is missing, install it:

sudo apt install curl -y

Permission Errors

Do not use sudo to install Rust with rustup.

Rust should be installed as a normal user.

Why We Use rustup

Rustup allows:

  • Managing multiple Rust versions
  • Updating Rust easily
  • Installing additional components
  • Keeping your system organized

To update Rust later, simply run:

rustup update

for more details go through the Rust Documentation