How to Install Rust on Rocky Linux 10, 9 and 8

Install Rust on Rocky Linux with rustup for current per-user tooling, or choose AppStream for DNF-managed servers, CI hosts, and shared workstations where package-managed updates matter.

PublishedAuthorJoshua JamesRead time6 minGuide typeRocky Linux

Before you install Rust on Rocky Linux, decide who should manage the toolchain. rustup gives your user account the current upstream stable release, while Rocky AppStream keeps Rust tied to normal DNF package management. That choice affects Cargo projects, editor tooling, updates, and cleanup.

Both methods work on Rocky Linux 10, 9, and 8. AppStream installs the rust compiler package and the separate cargo package under system paths. rustup installs rustc, Cargo, rustup, and default development components under ~/.cargo and ~/.rustup for your account.

Install Rust on Rocky Linux

Choose a Rust Installation Method

Use rustup for day-to-day Rust development, especially when you need the current stable channel, editor components, or per-project toolchain control. Use AppStream when you prefer DNF-managed packages for servers, CI runners, shared workstations, or conservative update policies.

MethodSourceToolchain ScopeUpdatesBest For
rustuprustup.rsCurrent upstream stable channel per user accountrustup updateMost development work, editor components, per-user installs
Rocky AppStreamRocky Linux repositoriesRocky-maintained package branch; standard RPM builds on Rocky Linux 10 and 9, module-flavored builds on Rocky Linux 8dnf upgradeSystem-managed Rust, CI hosts, package-maintained servers, conservative update policy

Use one method as your main Rust install in a normal shell. rustup and AppStream can coexist, but rustc and cargo run from whichever directory appears first in your shell’s PATH.

Update Rocky Linux Before Installing Rust

Refresh package metadata and apply pending updates before installing development tools. On shared workstations or build servers, review the DNF transaction before you confirm it.

sudo dnf upgrade --refresh

Package-management commands use sudo because they modify system directories. If metadata downloads are consistently slow, tune mirrors and parallel downloads with the Rocky-specific steps to increase DNF speed on Rocky Linux.

Install Rust with rustup on Rocky Linux

Install rustup when you want Rust managed inside your own account instead of by system RPM packages. Install gcc at the same time so Cargo can find the cc linker used by many Rust builds, including the test project you create after installation.

sudo dnf install curl ca-certificates gcc

Use the curl command in Linux to download Rust’s official installer. The --proto and --tlsv1.2 options require HTTPS, and sh -s -- -y accepts the default stable toolchain without opening the interactive menu.

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

Use the source command in Linux to load Cargo’s environment file so the current shell can find rustc, cargo, and rustup. New terminal sessions normally load the same path automatically after rustup updates your shell startup files.

source "$HOME/.cargo/env"

Verify the compiler, Cargo, and active toolchain:

rustc --version && cargo --version
rustup show active-toolchain

A successful rustup install on a Rocky Linux 10 x86_64 system should look similar to this:

rustc 1.96.0 (ac68faa20 2026-05-25)
cargo 1.96.0 (30a34c682 2026-05-25)
stable-x86_64-unknown-linux-gnu (default)

Install Rust from Rocky AppStream

Use the AppStream method when you want DNF to install, update, and remove Rust like other system packages. Rocky’s compiler package is named rust, not rustc, so install rust together with cargo.

sudo dnf install rust cargo

DNF also brings in rust-std-static and a working C compiler path when they are not already installed. Confirm the package names and command paths before moving on:

rpm -q rust cargo rust-std-static
command -v rustc cargo cc
rust-1.92.0-1.el10.x86_64
cargo-1.92.0-1.el10.x86_64
rust-std-static-1.92.0-1.el10.x86_64
/usr/bin/rustc
/usr/bin/cargo
/usr/bin/cc

On Rocky Linux 9, expect the same Rust branch with el9 package suffixes. Rocky Linux 8 uses a module-style AppStream build string such as module+el8.10.0. In all three releases, the installed commands still resolve to /usr/bin/rustc and /usr/bin/cargo.

Check the command versions after DNF finishes:

rustc --version && cargo --version
rustc 1.92.0 (ded5c06cf 2025-12-08) (Red Hat 1.92.0-1.el10)
cargo 1.92.0 (344c4567c 2025-10-21) (Red Hat 1.92.0-1.el10)

Build a Test Rust Project on Rocky Linux

A version check confirms the commands are on PATH, but a small Cargo project is a better first-use test. It confirms the compiler, Cargo, and local linker work together.

cargo new hello-rocky --bin
cd hello-rocky
cargo run --quiet
Hello, world!

Use cargo run --release when you want an optimized build instead of the default development profile. If your project uses source control, install Git on Rocky Linux before you start committing Rust projects.

Some crates with native build steps need more than GCC. Install CMake on Rocky Linux only when a crate or project build script asks for it.

Add Rust Development Tools on Rocky Linux

The default rustup profile already includes clippy and rustfmt. Add rust-analyzer when you want language-server support for completions, diagnostics, and jump-to-definition in editors such as Visual Studio Code on Rocky Linux.

rustup component add rust-analyzer

Confirm the core rustup components:

rustup component list --installed | grep -E 'clippy|rustfmt|rust-analyzer'
clippy-x86_64-unknown-linux-gnu
rust-analyzer-x86_64-unknown-linux-gnu
rustfmt-x86_64-unknown-linux-gnu

For AppStream installs, use Rocky’s separate RPM packages instead of rustup components. The linter package is named clippy, not rust-clippy, and these packages follow the same AppStream branch as the compiler.

sudo dnf install rustfmt clippy rust-analyzer rust-src

Verify the AppStream tools and the source package path:

command -v rustfmt cargo-clippy clippy-driver rust-analyzer
test -d /usr/lib/rustlib/src/rust/library && echo "rust-src is installed"
/usr/bin/rustfmt
/usr/bin/cargo-clippy
/usr/bin/clippy-driver
/usr/bin/rust-analyzer
rust-src is installed

Manage Rust Updates on Rocky Linux

Update Rust with the same tool that installed it. DNF does not update a rustup-managed toolchain, and rustup does not update AppStream RPM packages.

Update Rust installed with rustup

rustup refreshes installed toolchains and components for your user account:

rustup update
info: syncing channel updates for stable-x86_64-unknown-linux-gnu
  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.96.0 (ac68faa20 2026-05-25)
info: checking for self-update (current version: 1.29.0)
info: cleaning up downloads & tmp directories

When a newer stable release is available, the same command downloads the updated toolchain and components instead of reporting the toolchain as unchanged.

Update Rust installed from AppStream

DNF updates AppStream Rust packages during normal system maintenance. Use a targeted upgrade when you only want to check the core Rust packages:

sudo dnf upgrade --refresh rust cargo

If you installed optional tools such as rustfmt, clippy, rust-analyzer, or rust-src, include only the packages that are present on your system. Rerun rustc --version && cargo --version after the upgrade if you need to confirm the package branch changed.

Troubleshoot Rust on Rocky Linux

Most first-time Rust issues on Rocky Linux come from the current shell not loading Cargo’s path, mixed rustup/AppStream installs, or a missing C linker on minimal systems.

Rust command not found after rustup

If the current shell cannot find rustc, cargo, or rustup after a rustup install, check whether Cargo’s binary directory is already loaded:

case ":$PATH:" in
  *":$HOME/.cargo/bin:"*) echo "Rust PATH is loaded" ;;
  *) echo "Rust PATH is missing" ;;
esac
Rust PATH is loaded

If the check prints Rust PATH is missing, load the environment file in the current shell and verify again:

source "$HOME/.cargo/env"
rustc --version && cargo --version

Check Which Rust Command Is First on PATH

When rustup and AppStream are both installed, check which rustc command your shell will run before changing packages:

rustc_path=$(command -v rustc 2>/dev/null || true)
case "$rustc_path" in
  "$HOME/.cargo/bin/rustc") echo "rustup rustc is first on PATH" ;;
  /usr/bin/rustc) echo "AppStream rustc is first on PATH" ;;
  "") echo "rustc is not installed or PATH is not loaded" ;;
  *) echo "unexpected rustc path: $rustc_path" ;;
esac
rustup rustc is first on PATH

To keep rustup in charge, source ~/.cargo/env or open a new terminal. To keep AppStream in charge, remove the rustup toolchain or adjust your shell profile so ~/.cargo/bin no longer appears before /usr/bin.

Cargo build fails because cc is missing

A missing linker usually appears when Cargo compiles the first project or a crate with native code. Check for the standard C compiler path first:

command -v cc || echo "cc is missing"
cc is missing

Install GCC, then rerun the failed Cargo command:

sudo dnf install gcc
cargo run --quiet

Remove Rust from Rocky Linux

Remove Rust with the same method that installed it. rustup removes user-owned toolchains, while DNF removes RPM packages from system directories.

Remove Rust installed with rustup

This command removes rustup-managed toolchains, Cargo binaries, and the profile lines rustup added for your account. The -y flag skips the confirmation prompt.

Removing rustup also deletes ~/.cargo and ~/.rustup for the current account, including Cargo-installed command-line tools and local toolchain caches. Back up or reinstall any user-installed Cargo tools you still need.

rustup self uninstall -y
info: removing rustup home
info: removing cargo home
info: removing rustup binaries
info: rustup is uninstalled

rustup does not remove your Rust project directories. Confirm the toolchain directories are gone from the current account:

for name in .cargo .rustup; do
  path="$HOME/$name"
  [ -e "$path" ] && echo "still present: ~/$name" || echo "removed: ~/$name"
done
removed: ~/.cargo
removed: ~/.rustup

Remove Rust installed from AppStream

Check which AppStream Rust packages are installed before removal, especially if you did not install the optional tooling packages:

rpm -q rust cargo rust-std-static rustfmt clippy rust-analyzer rust-src

Remove the core AppStream compiler and Cargo packages first:

sudo dnf remove rust cargo

Remove optional Rust tooling packages only if they are installed:

optional_rust_tools=()
for pkg in rustfmt clippy rust-analyzer rust-src; do
  rpm -q "$pkg" >/dev/null 2>&1 && optional_rust_tools+=("$pkg")
done

if [ "${#optional_rust_tools[@]}" -gt 0 ]; then
  sudo dnf remove "${optional_rust_tools[@]}"
else
  echo "No optional AppStream Rust tooling packages are installed"
fi

DNF may also offer to remove Rust dependencies that are no longer needed. Preview broader dependency cleanup separately before accepting it on a reused workstation or build server:

sudo dnf autoremove --assumeno

Confirm the AppStream RPM packages are gone:

remaining=0
for pkg in rust cargo rust-std-static rustfmt clippy rust-analyzer rust-src; do
  if rpm -q "$pkg" >/dev/null 2>&1; then
    echo "still installed: $pkg"
    remaining=1
  fi
done
[ "$remaining" -eq 0 ] && echo "Rocky Rust packages are not installed"
Rocky Rust packages are not installed

Check for Leftover Rust Commands

After either removal path, clear Bash’s command cache and check whether another method still provides Rust commands on PATH. A remaining /usr/bin path points to AppStream, while a path under ~/.cargo/bin points to rustup.

hash -r
for cmd in rustc cargo rustup; do
  path=$(command -v "$cmd" 2>/dev/null || true)
  if [ -n "$path" ]; then
    echo "$cmd still resolves to $path"
  else
    echo "$cmd is not on PATH"
  fi
done
rustc is not on PATH
cargo is not on PATH
rustup is not on PATH

Conclusion

Rust is ready on Rocky Linux through either a current rustup-managed toolchain or Rocky’s AppStream packages. Use rustup for fast-moving project work, use AppStream for package-managed systems, and keep the PATH checks handy if both methods have been installed. Use The Rust Book as you move beyond the first Cargo project.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<a href="https://example.com">link</a> link
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: