How to Install Rust on Manjaro Linux

Rust, a contemporary systems programming language, boasts safe concurrency, high performance, and granular control over hardware. Developed by Mozilla in 2010, Rust has gained substantial traction, amassing a dedicated developer community and a burgeoning library and tool ecosystem.

What sets Rust apart is its emphasis on memory and thread safety. The language’s innovative ownership system averts memory errors like null pointer dereferences and buffer overflows at compile-time, ensuring safe, reliable code. Additionally, Rust’s support for asynchronous programming empowers developers to create concurrent code free from data races and deadlocks.

Rust’s performance, safety, and modern features have propelled its adoption by companies like Microsoft, Dropbox, and Mozilla for building high-performance systems and software. The growing Rust community has enriched its ecosystem with diverse tools and libraries, including web frameworks, game engines, and database drivers.

To begin your Rust journey, follow our guide below on installing Rust on Manjaro Linux using the official Rust installation script installer, bypassing the need for third-party repositories such as the AUR.

Step 1: Update Manjaro

Before installing Rust on your Manjaro Linux system, it is important to ensure your system is up-to-date. This will help ensure you have installed the latest security patches and software updates.

To update your system, you can run the following command in your terminal:

sudo pacman -Syu

Step 2: Install Rust Programming Language

First, ensure the curl package is installed; you can use the following command in your terminal:

sudo pacman -S curl

To install Rust, you can use the following command in your terminal:

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

This command will download the Rust installation script using curl and execute it. The installation script will guide you through the installation process and allow you to customize the installation if desired.

For most users, installing the default Type 1 option is recommended. If you choose to customize your installation, you can review the options and choose the ones that best suit your needs. The installation process should take 1 to 5 minutes, depending on your server’s internet speed and hardware.

The installation process should take 1 to 5 minutes, depending on your server’s internet speed and hardware.

Once the installation is complete, you must activate the Rust environment for your current shell. This can be done using the following command:

source "$HOME/.cargo/env"

After activating the Rust environment, you can verify the version of Rust installed by running the following command:

rustc -V

If the version build of Rust is printed out, it means that Rust has been successfully installed on your system. However, if you cannot print out the version build, it means that you have not activated the Rust environment shell. Ensure that you have activated the Rust environment before trying to verify the Rust installation again.

Step 3: Test Rust by Creating Rust Programs

After installing Rust on your Manjaro Linux system, you may want to test your installation to ensure everything works correctly.

Test: Hello, World!

The test project we will use is the classic “Hello, World!” program. This simple program prints the message “Hello, World!” to the terminal.

To create this program, open your text editor and create a new file called main.rs.

nano main.rs

Inside this file, add the following code:

fn main() {
    println!("Hello, World!");
}

Save the file and exit your text editor. Then, in your terminal, navigate to the directory where you saved the main.rs file and use the following command to compile and run the program:

rustc main.rs && ./main

If everything works correctly, you should see the message “Hello, World!” printed to your terminal.

Additional Tips

How to Update Rust

Keeping your Rust installation up-to-date ensures you have the latest features and security patches. Updating Rust on your Manjaro Linux system is straightforward and can be done using a single command in your terminal.

To update Rust, you can use the following command in your terminal:

rustup update

This command will update your Rust installation to the latest version available. Depending on your internet connection speed and update size, the process may take a few minutes.

How to Remove (Uninstall) Rust

If you no longer need Rust on your Manjaro Linux system, you can easily remove it using a simple command in your terminal.

To uninstall Rust, you can use the following command in your terminal:

rustup self uninstall

This command will remove Rust entirely from your system, including all its components and associated packages.

You will then get the following result Rust has been successfully removed from your system.

Conclusion

Installing Rust on your Manjaro Linux system is a simple and easy process that can be done using the official Rust installation script installer. This guide has explained the steps you need to take to install Rust, verify your installation using test projects, keep your installation up-to-date, and remove Rust from your system if necessary.

Your Mastodon Instance
Share to...