Rust Programming Language is a new language from Mozilla and the Rust team that was designed to bring modern programming language features and high performance to systems programming. It has many new concepts, though it is still a work in progress, so do not expect it to be perfect.
Rust is a remarkable project, as its goal of creating one trustworthy compiler for safe code is slowly developing into reality. A responsible system programmer can trust Rust to provide them with an end-to-end system of compilation, analysis, and runtime support that’s free of undefined behaviors or other exploitable flaws.
Rust is not just a language, but also an ecosystem. Rust has tools and libraries that together make building fast and secure systems easy.
The learning curve in this language is steep, but you won’t be alone, as the community behind Rust is great and very active. When you first start using Rust, you usually compile from source, so it’s important to understand the tooling around it.
Most Rust users use rustup to install Rust and its tooling. Rust itself is distributed via a self-contained package manager called Cargo, which installs the compiler, documentation, and various tools that make development easier. Cargo has built-in support for installing source dependencies with git or GitHub URLs, managing local dependencies with a lock file, and installing binary dependencies from the ‘crates.io’ package repository.
You heard rust is coming, and that it’s a major game changer. You’re trying to install Rust on your Linux system, but the installation doesn’t go as you expect. It’s very likely that you don’t have the proper dependencies, or the compiler is missing. The following article explains how to prepare your system for Rust and then install it.
In order to install Rust on your Rocky Linux 8 system, you will need the following:
- Root access. The installation process may download and install to a user’s home directory, so it’s very important to have sufficient access permissions to your home directory in order to run sudo. You can learn how to do this here.
- A system running Rocky Linux 8 with at least 2 GB memory and 20 GB of free disk space.
- A working Internet connection to download and install the installer script.
Updating Your System
Before installing Rust, it is important to verify that all of your packages are up to date.
Run the following command as root:
sudo dnf check-update && sudo dnf update -y
Once the update process finishes, run the command below to install the epel-release (Extra Packages for Enterprise Linux) repository. epel-release is a CentOS and Red Hat Enterprise Linux repository configuration tool. It provides additional repositories that are not enabled by default. Most notably EPEL (Extra Packages for Enterprise Linux), is an additional repository containing high-quality add-on packages that complement the CentOS and RHEL operating systems.
sudo dnf install epel-release -y
Finally, run the command below to install the required dependencies. Without these dependencies, your RUST compiler tools will not work properly.
You will install:
- cmake: CMake is a cross-platform, open-source build system generator. It is a family of tools designed to build, test and package software.
- gcc: GNU Compiler Collection (GCC) is a compiler system produced by the GNU Project supporting various programming languages. GCC is available for many platforms, including UNIX, Microsoft Windows and Mac OS X. It features a number of back-ends that can produce machine code from a single high-level language.
- make: make is a build utility that automatically builds executable programs and libraries from source code through successive stages of compilation. The name make is derived from the term make up meaning “to construct” something.
- curl: a command-line download utility used to download files from the RUST server
- clang: Clang is a C, C++ and Objective-C compiler front end for the LLVM compiler. It is designed to provide a framework for creating compilers. Clang continues to be supported as a computer-only compiler, but it now provides the core features expected in a full-featured production compiler.
sudo dnf install cmake gcc make curl clang -y
Install Rust on Rocky Linux 8
Now that your system is up to date and the required dependencies are installed, you can install Rust on your Rocky Linux 8 system.
You can install Rust via snapd, or build from the source. You can also make a docker image and pull it from the public docker hub to install rust. This demo uses the installer script of its developer. When you use the installer script from an official link, it will always download the latest stable version of rust, which runs nicely on most distros.
Run the command below to download the Rust installer script.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl –proto is a new curl option that enables TLS v1.2 protocol by default, –proto ‘=https’ disables all other protocols but https. –tlsv1.2 enables any TLS v1.2 compatible SSL implementation to be used. -sS skips the output, sh defines the installer script to be downloaded and run.
Type 1 and press Enter when prompted.
The installation might take a while to complete. Once the installation process finishes, you will get the following output.
Run the source ~/.profile command to restart your current shell. source is a command in Unix-like operating systems that instructs the current shell to apply changes made by the commands contained in the specified file. source is meant to be run in the current shell, but it is also possible to open another shell and have it execute commands from the specified file(s) there.
Run the source ~/.cargo/env command to set up your workspace. source ~/.cargo/env will read the contents of ~/.cargo/env into your shell’s environment, this enables you to use cargo without having to manually add it to each new shell you create.
Finally, run the command below to check your Rust version.
You will get the following output.
Rust is a reliable, efficient language. As it matures, it will be used by more and more.
That is all there is to installing the Rust Programming Language on your Rocky Linux 8 system. If you are experiencing problems, feel free to let us know in the comments.
For more information about Rust visit the official website.