MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

AlmaLinux Rust

without comments

Installed the Rust programming language on AlmaLinux as a sudoer user with this command:

sudo yum install -y rust

Wrote a simple Hello World! program, as qualified in the Rust Programming language online reference. Only, I changed the name of the file to hello.rs rather than main.rs because I thought that beginning programmers might not tell the difference between a program name and the main function.

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

Compiled the program with:

rustc hello.rs

Then, ran the generated hello executable file from its local directory:

./hello

It printed:

Hello World!

You need to install cargo, which is the Rust Programming Language’s package manager to build anything other than the simplest examples. The easiest way to install the cargo package manager at this point is to type:

cargo --version

It’ll tell you that it isn’t installed on a fresh AlmaLinux environment and prompt you to install it, as shown:

Install package 'cargo' to provide command 'cargo'? [N/y] y
 
 
 * Waiting in queue... 
 * Loading list of packages.... 
The following packages have to be installed:
 cargo-1.58.1-1.el9.x86_64	Rust's package manager and build tool
Proceed with changes? [N/y] y
 
 
 * Waiting in queue... 
 * Waiting for authentication... 
 * Waiting in queue... 
 * Loading list of packages.... 
 * Downloading packages... 
 * Requesting data... 
 * Testing changes... 
 * Installing packages... 
cargo 1.58.0

I’m hoping that introducing Rust to the blog may encourage more exploration of the Rust Programming Language.

Written by maclochlainn

October 30th, 2022 at 1:11 pm

Posted in AlmaLinux

Tagged with ,