This article will take you through how to install Rust on Rocky Linux 9. Rust is a general-purpose programming language with a focus on performance, type safety, and concurrency. Rust enforces memory safety, which means that all references point to valid memory without the use of a garbage collector or reference counting, both of which are required in other memory-safe languages.
How to Install Rust on Rocky Linux 9
- Update Rocky Linux 9.
sudo dnf update
- Install the EPEL repository using the command below.
sudo dnf install epel-release -y
- Next, install dependencies such as curl, etc.
sudo dnf install cmake gcc make curl clang -y
Sample output
Dependencies resolved. ===================================================================== Package Arch Version Repo Size ===================================================================== Installing: clang x86_64 13.0.1-1.el9 appstream 81 k cmake x86_64 3.20.2-7.el9 appstream 6.7 M gcc x86_64 11.2.1-9.4.el9 appstream 32 M make x86_64 1:4.3-7.el9 baseos 530 k Installing dependencies: clang-libs x86_64 13.0.1-1.el9 appstream 22 M clang-resource-filesystem x86_64 13.0.1-1.el9 appstream 12 k cmake-data noarch 3.20.2-7.el9 appstream 1.5 M cmake-filesystem x86_64 3.20.2-7.el9 appstream 16 k cmake-rpm-macros noarch 3.20.2-7.el9 appstream 15 k gcc-c++ x86_64 11.2.1-9.4.el9 appstream 13 M glibc-devel x86_64 2.34-28.el9_0 appstream 29 k glibc-headers x86_64 2.34-28.el9_0 appstream 426 k kernel-headers x86_64 5.14.0-70.22.1.el9_0 appstream 1.9 M libstdc++-devel x86_64 11.2.1-9.4.el9 appstream 2.2 M libxcrypt-devel x86_64 4.4.18-3.el9 appstream 28 k Installing weak dependencies: compiler-rt x86_64 13.0.1-1.el9 appstream 2.5 M libomp x86_64 13.0.1-1.el9 appstream 943 k libomp-devel x86_64 13.0.1-1.el9 appstream 29 k Transaction Summary ===================================================================== Install 18 Packages Total download size: 84 M Installed size: 327 M Downloading Packages: (1/18): libomp-devel-13.0.1-1.el9.x8 40 kB/s | 29 kB 00:00 (2/18): make-4.3-7.el9.x86_64.rpm 300 kB/s | 530 kB 00:01 (3/18): cmake-rpm-macros-3.20.2-7.el 15 kB/s | 15 kB 00:01 (4/18): cmake-filesystem-3.20.2-7.el 179 kB/s | 16 kB 00:00 (5/18): libomp-13.0.1-1.el9.x86_64.r 302 kB/s | 943 kB 00:03 (6/18): cmake-data-3.20.2-7.el9.noar 281 kB/s | 1.5 MB 00:05 (7/18): libxcrypt-devel-4.4.18-3.el9 1.6 kB/s | 28 kB 00:17 (8/18): cmake-3.20.2-7.el9.x86_64.rp 213 kB/s | 6.7 MB 00:32 (9/18): clang-resource-filesystem-13 1.1 kB/s | 12 kB 00:10 (10/18): compiler-rt-13.0.1-1.el9.x8 71 kB/s | 2.5 MB 00:35 (11/18): clang-13.0.1-1.el9.x86_64.r 11 kB/s | 81 kB 00:07 (12/18): clang-libs-13.0.1-1.el9.x86 315 kB/s | 22 MB 01:12 (13/18): libstdc++-devel-11.2.1-9.4. 35 kB/s | 2.2 MB 01:05 (14/18): kernel-headers-5.14.0-70.22 28 kB/s | 1.9 MB 01:11 (15/18): glibc-headers-2.34-28.el9_0 18 kB/s | 426 kB 00:23 (16/18): gcc-c++-11.2.1-9.4.el9.x86_ 415 kB/s | 13 MB 00:31 (17/18): glibc-devel-2.34-28.el9_0.x 5.6 kB/s | 29 kB 00:05 (18/18): gcc-11.2.1-9.4.el9.x86_64.r 281 kB/s | 32 MB 01:57 --------------------------------------------------------------------- Total 378 kB/s | 84 MB 03:47 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded.
- Install Rust on Rocky Linux 9 using the following command.
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 %) 466.8 KiB/s in 1s 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 %) 670.3 KiB/s in 10s ETA: 0s info: downloading component 'clippy' 2.8 MiB / 2.8 MiB (100 %) 826.8 KiB/s in 3s ETA: 0s info: downloading component 'rust-docs' 18.3 MiB / 18.3 MiB (100 %) 921.6 KiB/s in 23s ETA: 0s info: downloading component 'rust-std' 26.1 MiB / 26.1 MiB (100 %) 297.6 KiB/s in 53s ETA: 0s info: downloading component 'rustc' 54.3 MiB / 54.3 MiB (100 %) 646.8 KiB/s in 1m 33s ETA: 0s info: downloading component 'rustfmt' 4.1 MiB / 4.1 MiB (100 %) 601.7 KiB/s in 7s ETA: 0s info: installing component 'cargo' info: installing component 'clippy' info: installing component 'rust-docs' 18.3 MiB / 18.3 MiB (100 %) 2.2 MiB/s in 8s ETA: 0s info: installing component 'rust-std' 26.1 MiB / 26.1 MiB (100 %) 9.0 MiB/s in 3s ETA: 0s info: installing component 'rustc' 54.3 MiB / 54.3 MiB (100 %) 10.4 MiB/s in 5s 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"
- Next, activate the Rust environment on Rocky Linux 9.
source ~/.profile
source ~/.cargo/env
- Check the Rust version that is installed on your system.
rustc -V
- Use the following command to add rust compiler to Rocky Linux.
sudo dnf install rustc
Sample Rust Application
- Create a directory to store your application files.
mkdir myproject
- Navigate to the created directory.
cd myproject
- Next, create a sample app using the following command.
sudo nano helloguys.rs
Paste the code below then save(ctrl+s) and close(ctrl+x) the file.
fn main() {
println!("Hello from itnixpro.com!");
}
- Compile the created application above.
rustc helloguys.rs
- After compiling run it using the following command.
./helloguys
Update Rust on Rocky Linux
- Use the command below to update Rust.
rustup update
Uninstall Rust on Rocky Linux
- Remove Rust on your system by running the command below.
rustup self uninstall
- You have made it to the end of our tutorial, we have gone through how to install Rust on Rocky Linux 9. Cheers!
Read more about Rust
Other Tutorials
Install PHP 8 on Rocky Linux 9