| by Arround The Web | No comments

How to Install Rust on Debian 12 Bookworm

Rust is a robust programming language that is gaining attention with each day thanks to its unique and advanced features. It is a valuable language for embedded systems and is used in Industries like IoT and robotics. Rust is also gaining much attention among game developers since they use this language to develop powerful gaming applications and engines. The main purpose of using the Rust programming language is because it is fast, safe and runs multiple computations parallelly.

In this guide, you will find:

How to Install Rust on Debian 12

How to Use Rust on Debian 12

Conclusion

How to Install Rust on Debian 12

You can install Rust on Debian 12 from:

How to Install Rust on Debian 12 from Source Repository

The Debian’s source repository includes the installation of Rust, making it easy for you to install it on your system with a single command. However, before installing Rust on Debian 12, you should update the repository from the following command:

sudo apt update && sudo apt upgrade -y

Right after updating the repository, run the below-given command to install Rust on Debian 12:

sudo apt install rustc -y

To ensure Rust is installed on Debian, you can run the following command:

rustc --version

How to Remove Rust from Debian 12

You can remove Rust from Debian 12 installed through repository method by executing the below-given command:

sudo apt remove rustc -y

How to Install Rust on Debian 12 from Official Script

If you want to install the latest version of Rust on Debian 12, you can do it using the script provided by the official website. To install Rust on Debian 12 from the script, follow the below-given steps:

Step 1: Install Curl on Debian 12

First, you must install curl on your Debian system through the following command because it will be used later on to download the script file from the Internet:

sudo apt install curl -y

Step 2: Download and Run Rust Script on Debian 12

Now, download and run the script for Rust installation on Debian using the following command:

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

Step 3: Install Rust on Debian 12 from Script

At the execution of the script, you will be provided with several options to install Rust on Debian. However, to make things simple, go with the default option by typing 1 in the selection menu:

Step 4: Configure Current Shell

To make changes, you must configure your current shell, this can be done from the following command:

source $HOME/.cargo/env

Step 5: Check Rust Version on Debian

Now, run the following command to check for the installed Rust version on Debian:

rustc --version

Step 6: Check for Updates for Rust

If you want to check for Rust updates, you can use the rustup manager that is used to install and manage Rust packages. You can use the following command to check for updated Rust version if available:

rustup check

Step 6: Update Rust on Debian

If you want to update Rust on Debian, you can use the following command:

rustup update

Step 7: Install Other Version of Rust on Debian

You can also use the rustup manager to install other version of Rust on your Debian system, this can be done using the rustup install command followed by version number:

Step 8: Uninstall Rust from Debian 12

To uninstall Rust from Debian 12 installed through this method, you can simply use the rustup self command followed by the uninstall keyword. It will install a complete rustup setup from Debian including Rust as well.

rustup self uninstall

Bonus Method: How to Install Rust on Debian 12 from Snap Store

Snap Store is another effective package manager that allows the installation of various applications on your system, which doesn’t conflict with your other packages. You can also use the Snap Store service to install Rust on Debian 12. However, you cannot install Rust on Debian 12 from Snap Store directly because it is not available in the repository. You first have to install rustup manager from Snap Store on Debian through the following command:

sudo snap install rustup --classic

Note: To install Snap Store on Debian, you can use the following command:

sudo apt install snapd -y

Now use the rustup command followed by the Rust version you want to install, this can be done using the below-given syntax:

rustup install version_no

Or you can run rustup from the Snap Store and install any Rust version using the below-given command:

sudo snap run rustup install version_no

How to Use Rust on Debian 12

To learn how to use Rust on Debian 12 for programming, you can use the following steps:

Step 1: Create a File with .rs Extension

First, create a file using nano editor, add your Rust Programming code and save this file with a proper name with the .rs extension:

nano filename.rs

Here, I have added the following Rust code inside the file and name the file as hello.rs:

fn main() {

println!("Hello Linux Hint Users");

}

Step 2: Compile the Rust Code on Debian 12

You must compile your code with the rustc interpreter followed the filename you have created in the e:

rustc filename.rs

After the compilation, the rustc interpreter will create a file inside the directory where your Rust file is saved.

Step 3: Run the File

You can run your file on Debian using the following command:

./filename

Conclusion

Rust is a robust programming language that you can install on Debian directly from the official system repository. However, to install the latest version of Rust on Debian 12, you have to run the official script that installs Rust with the rustup package manager. Besides that, you can also use Snap Store to install rustup manager and install different versions of Rust programming language on your system. This guide has provided the installation and use of Rust, and after completing the installation, you will be able to start your journey with Rust on Debian 12.

Share Button

Source: linuxhint.com

Leave a Reply