Skip to main content

Installing Rust on Fedora

Rust is a modern programming language designed for performance, reliability, and productivity. In this tutorial, we will walk through the step-by-step process of installing Rust on Fedora. We will cover the installation from scratch, starting with the installation of necessary dependencies, setting up the Rust environment, and verifying the installation.

Prerequisites

Before we begin, make sure you have the following prerequisites:

  • A Fedora system with administrative privileges
  • An active internet connection

Let's get started!

Step 1: Update System Packages

It is always a good practice to update your system packages before installing any new software. Open a terminal and run the following command:

sudo dnf update

Enter your password if prompted and wait for the update process to complete.

Step 2: Install Required Dependencies

Rust requires several dependencies to be installed on your system. Open a terminal and execute the following command to install these dependencies:

sudo dnf install curl file

Enter your password if prompted and wait for the installation to finish.

Step 3: Download and Install Rust

To download and install Rust, we will use the rustup toolchain installer. This toolchain installer manages Rust versions and associated tools.

Run the following command in your terminal to download and install rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

This command will download a script and start the installation process.

After the script finishes, you will see output similar to the following:

Rust is installed now. Great!

Step 4: Configure the Rust Environment

To use Rust, you need to add the cargo and rustc binaries to your system's PATH variable. You can do this by running the following command:

source $HOME/.cargo/env

This command adds the necessary environment variables to your current session. You can also add this command to your shell configuration file (such as .bashrc or .zshrc) to automatically load the Rust environment variables every time you open a new terminal.

Step 5: Verify the Installation

To verify that Rust has been installed correctly, open a new terminal and run the following command:

rustc --version

You should see output similar to the following:

rustc x.y.z (abcabcabc yyyy-mm-dd)

This output confirms that Rust is installed and displays the current version number.

Step 6: Update Rust and Cargo

Rust and Cargo, the Rust package manager, receive regular updates. It is a good practice to keep them up to date.

To update Rust and Cargo, run the following command:

rustup update

This command will check for updates and install them if any are available.

Step 7: Uninstall Rust (Optional)

If you ever decide to uninstall Rust from your system, you can use the following command:

rustup self uninstall

This command will remove all Rust components from your system.

Conclusion

Congratulations! You have successfully installed Rust on your Fedora system. You can now start exploring the world of Rust programming.

Remember to regularly update Rust and Cargo to benefit from the latest features and bug fixes. If you encounter any issues or have questions, refer to the official Rust documentation or community forums for assistance.

Happy coding!