How to Install Rust on Fedora 39, 38 Linux

Rust, a modern programming language known for its safety and performance, is increasingly popular among developers seeking robustness and efficiency. In this guide, we’ll focus on demonstrating how to install Rust on Fedora Linux, a task essential for developers who value a streamlined and secure coding environment.

Key Features of Rust:

  • Safety: Rust emphasizes memory safety without sacrificing performance, drastically reducing common bugs in other languages.
  • Concurrency: Designed for modern computing, Rust offers advanced concurrency capabilities, making it ideal for handling multiple tasks simultaneously.
  • Performance: With its zero-cost abstractions, Rust delivers performance comparable to low-level languages like C.
  • Cross-platform Development: Rust supports a wide range of platforms, making it a versatile choice for various applications.
  • Rich Ecosystem: Rust’s growing ecosystem includes numerous libraries and tools, fostering an environment of continuous innovation and support.

Setting up Rust on Fedora Linux is an uncomplicated process, aligning with the needs of developers seeking efficiency and precision. Our guide will navigate you through two primary methods: installing the default Rust version available in Fedora’s appstream and utilizing the Rustup bash script for installing the most recent version on your Fedora system. This approach ensures you have access to the latest features and improvements in the Rust environment, tailored to Fedora’s reliable and cutting-edge platform.

Install Rust on Fedora Linux via Default Appstream

Step 1: Update Fedora Packages Before Rust Installation

To begin, it’s crucial to start with an updated system. Updating your Fedora ensures that all packages, including dependencies required for Rust, are current. This step minimizes potential conflicts and ensures a smoother installation process.

Execute the following command in your terminal to update the packages:

sudo dnf upgrade --refresh

This command refreshes your repository cache and upgrades all your system’s packages to their latest versions.

Step 2: Install Rust on Fedora via DNF Command

Once your system is up to date, you can proceed to install Rust. Fedora’s package manager, DNF, allows for a straightforward installation of Rust.

In your terminal, execute the following command:

sudo dnf install rust cargo

This command installs several key components of the Rust programming environment:

  • rustc: The Rust compiler, essential for converting your Rust code into executable binaries.
  • Standard Library: Provides a collection of standard functionalities and types, crucial for Rust programming.
  • GDB Support: Integrates with the GNU Debugger, enhancing the debugging experience for Rust programs.
  • rustdoc: A documentation generator that helps you create documentation for your Rust code.
  • Cargo: Rust’s package manager and build system, streamlining the process of managing dependencies and building your Rust projects.

By executing this command, you equip your Fedora system with all the necessary tools to start developing in Rust, ensuring a comprehensive and efficient programming setup. For another installation method, check out the next section using the Rustup script to install Rust on Fedora Linux.

Install Rust on Fedora Linux via RustUp

Step 1: Update Fedora Packages

Begin by ensuring your Fedora system is fully updated. This step is crucial as it prepares the system with the latest updates and patches, reducing the risk of compatibility issues during Rust installation.

Execute the command below in your terminal:

sudo dnf upgrade --refresh

This command will refresh the system’s package database and upgrade all installed packages to their most recent versions.

Step 2: Install Specific Packages

Prior to installing Rust, it’s necessary to install certain prerequisite packages. These packages are essential for the successful installation and operation of Rust on your Fedora system. Run the following command:

sudo dnf install curl dnf-plugins-core cmake gcc clang make -y

This command installs various tools and compilers, including:

  • curl: A tool for transferring data with URL syntax, essential for downloading files.
  • dnf-plugins-core: Enhances DNF’s functionality.
  • cmake: A cross-platform build system.
  • gcc: The GNU Compiler Collection, a standard compiler for C programming.
  • clang: A compiler for C, C++, and Objective-C.
  • make: A build automation tool.

These tools collectively ensure your system is fully equipped to handle the Rust installation process.

Step 3: Install Rust on Fedora via RustUp Script

With the necessary packages in place, proceed to download and run the Rust installation script. The RustUp script is a convenient and reliable method for installing Rust.

Use the following command:

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

This command fetches the RustUp script securely and initiates the installation. During the installation process, you will be prompted with instructions.

Follow these prompts to complete the setup.

Terminal Prompt During Rust Installation via RustUp on Fedora
Terminal view of Rust installation process using RustUp on Fedora

The installation time can vary from 1 to 5 minutes, depending on your server’s internet connection and hardware capabilities.

Successful Installation of Rust Language on Fedora Linux
Terminal Output Showing Successful Rust Installation on Fedora

After the installation, activate the Rust environment in your current shell with the following command:

source ~/.cargo/env

This command configures your shell environment to access Rust’s tools and utilities.

To verify the successful installation of Rust, check the installed version:

rustc -V

This command displays the installed version of Rust, confirming that Rust has been successfully installed on your Fedora system.

Additional Commands With Rust on Fedora Linux

Update Rust on Fedora

DNF Update Command for Rust

Regularly updating Rust ensures you have the latest features and security patches. For Rust installations via Fedora’s appstream, use the DNF package manager. This command not only updates Rust but also checks and updates all Fedora packages:

sudo dnf upgrade --refresh

RustUp Update Command for Rust

For Rust installations via RustUp, updating is a streamlined process. RustUp directly communicates with the official Rust source to fetch updates. Run the following command in your terminal to update Rust:

rustup update
Updating Rust Language Using RustUp on Fedora Linux
Terminal Output of Rust Language Update on Fedora

After updating, activate the Rust environment in your current shell for the updates to take effect:

source ~/.cargo/env

To verify the update, you can check the installed version of Rust:

rustc -V

Remove Rust (Uninstall) From Fedora

DNF Remove Command for Rust

If you need to uninstall Rust installed via Fedora’s DNF, the process is straightforward. This command removes Rust along with its package manager, Cargo:

sudo dnf remove rust cargo

RustUp Remove Command for Rust

For installations done through RustUp, Rust provides an efficient uninstallation process. This command cleanly removes Rust and its associated files from your Fedora system:

rustup self uninstall
Removing Rust Language from Fedora Linux using RustUp
Terminal View of Rust Removal Using RustUp on Fedora

Upon executing this command, you’ll receive a confirmation indicating that Rust has been successfully removed from your system.

Conclusion

Wrapping up, setting up Rust on Fedora Linux is a clear-cut task, and following this guide should have made the process smooth for you. From updating your Fedora system to installing Rust, either through the default appstream or via the RustUp script, we’ve covered the essentials to get you up and running. This guide also detailed how to keep Rust updated and the straightforward steps to uninstall it if necessary. With Rust now at your fingertips, you’re well-equipped to tackle projects that demand safety, speed, and reliability. Remember, regular updates are key to maintaining Rust’s efficiency and security. Happy coding!

Leave a Comment