Install Rust on Linux Mint 21

0
777
Install Rust on Linux Mint 21
Install Rust on Linux Mint 21

This guide will go through how to install Rust on Linux Mint 21. Rust is a multi paradigm, general-purpose programming language that emphasizes on performance, type safety, and concurrency. It ensures memory safety, which requires that all references point to legitimate memory, without requiring the use of a garbage collector or reference counting, which are required in other memory-safe languages.

Table of Contents

- Advertisement -

How to Install Rust on Linux Mint 21

Update Linux Mint packages.

sudo apt update

Next, install the following dependencies.

sudo apt install curl build-essential gcc make

Sample output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
gcc is already the newest version (4:11.2.0-1ubuntu1).
make is already the newest version (4.3-4.1build1).
The following additional packages will be installed:
  g++ g++-11 libc-dev-bin libc-devtools libc6-dev libcrypt-dev libcurl4
  libnsl-dev libstdc++-11-dev libtirpc-dev rpcsvc-proto
Suggested packages:
  g++-multilib g++-11-multilib gcc-11-doc glibc-doc libstdc++-11-doc
The following NEW packages will be installed:
  build-essential g++ g++-11 libc-dev-bin libc-devtools libc6-dev
  libcrypt-dev libnsl-dev libstdc++-11-dev libtirpc-dev rpcsvc-proto
The following packages will be upgraded:
  curl libcurl4
2 upgraded, 11 newly installed, 0 to remove and 77 not upgraded.
Need to get 16.6 MB of archives.
After this operation, 64.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc-dev-bin amd64 2.35-0ubuntu3.1 [20.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 libcrypt-dev amd64 1:4.4.27-1 [112 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 rpcsvc-proto amd64 1.4.2-0ubuntu6 [68.5 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libtirpc-dev amd64 1.3.2-2ubuntu0.1 [192 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 libnsl-dev amd64 1.3.0-2build2 [71.3 kB]
Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc6-dev amd64 2.35-0ubuntu3.1 [2,099 kB]
Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 libstdc++-11-dev amd64 11.2.0-19ubuntu1 [2,083 kB]
Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 g++-11 amd64 11.2.0-19ubuntu1 [11.4 MB]
Get:9 http://archive.ubuntu.com/ubuntu jammy/main amd64 g++ amd64 4:11.2.0-1ubuntu1 [1,412 B]
Get:10 http://archive.ubuntu.com/ubuntu jammy/main amd64 build-essential amd64 12.9ubuntu3 [4,744 B]
Get:11 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 curl amd64 7.81.0-1ubuntu1.4 [194 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcurl4 amd64 7.81.0-1ubuntu1.4 [290 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libc-devtools amd64 2.35-0ubuntu3.1 [28.9 kB]
Fetched 16.6 MB in 2min 8s (130 kB/s)   

Then install Rust on Linux Mint 21.

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

Sample output

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
703.5 KiB / 703.5 KiB (100 %) 159.7 KiB/s in  5s ETA:  0s
info: latest update on 2022-08-11, rust version 1.63.0 (4b91a6ea7 2022-08-08)
info: downloading component 'cargo'
  6.6 MiB /   6.6 MiB (100 %) 121.5 KiB/s in 40s ETA:  0s 
info: downloading component 'clippy'
  2.8 MiB /   2.8 MiB (100 %) 163.2 KiB/s in 31s ETA:  0s
info: downloading component 'rust-docs'
 18.3 MiB /  18.3 MiB (100 %) 758.4 KiB/s in 33s ETA:  0s    
info: downloading component 'rust-std'
 26.1 MiB /  26.1 MiB (100 %) 296.2 KiB/s in 57s ETA:  0s
info: downloading component 'rustc'
 54.3 MiB /  54.3 MiB (100 %) 370.6 KiB/s in  3m 12s ETA:  0s    
info: downloading component 'rustfmt'
  4.1 MiB /   4.1 MiB (100 %) 272.9 KiB/s in 12s ETA:  0s
info: installing component 'cargo'
  6.6 MiB /   6.6 MiB (100 %)   5.4 MiB/s in  1s ETA:  0s
info: installing component 'clippy'
info: installing component 'rust-docs'
 18.3 MiB /  18.3 MiB (100 %)   1.3 MiB/s in 22s ETA:  0s
info: installing component 'rust-std'
 26.1 MiB /  26.1 MiB (100 %)   5.6 MiB/s in  5s ETA:  0s
info: installing component 'rustc'
 54.3 MiB /  54.3 MiB (100 %)   7.8 MiB/s in  7s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.63.0 (4b91a6ea7 2022-08-08)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"

Activate Rust environment.

source ~/.profile
source ~/.cargo/env

Check the version of Rust installed.

rustc -V

Next, install the rust compiler using the following command.

sudo apt install rustc

Sample Rust application

Create a directory where your project will be stored.

sudo mkdir ~/projects

Go to the created directory.

cd ~/demo-project

Next, create a sample app.

sudo nano hellolinux.rs

Copy and paste the sample code below. Save(ctrl+s) and close(ctrl+x) the file.

fn main() {
println!("Hello from linuxkatas.com");
}

Compile your application using the command below.

sudo rustc hellolinux.rs

Then run it using the following command.

./hellolinux

Update Rust on Linux Mint 21

Update Rust programming language using the command below.

rustup update

Uninstall Rust on Linux Mint 21

Remove Rust from your system using the following command.

rustup self uninstall

Sample output

Thanks for hacking in Rust!

This will uninstall all Rust toolchains and data, and remove
$HOME/.cargo/bin from your PATH environment variable.

Continue? (y/N) y

info: removing rustup home
info: removing cargo home
info: removing rustup binaries
info: rustup is uninstalled

You have made it to the end of our article on how to install Rust on Linux Mint 21. Cheers!

Read more about Rust

Other Tutorials

How To Install phpMyAdmin on Rocky Linux 9/AlmaLinux 9

Install Apache Tomcat 10 on Rocky Linux 9 / Almalinux 9

How to Install Docker CE on Rocky Linux 9 / AlmaLinux 9

LEAVE A REPLY

Please enter your comment!
Please enter your name here