Skip to content
Latchkey

dnf install: Usage, Options & Common CI Errors

dnf install adds packages and dependencies on Fedora, RHEL 8+, Rocky, and AlmaLinux.

dnf is the modern successor to yum on the Red Hat family. In CI you pass -y to skip prompts; the most common failures are misnamed packages and an unimported repo GPG key.

What it does

dnf install resolves dependencies and installs the named packages from the enabled repositories. It caches metadata automatically (no separate "update index" step is required), and supports groups (@development-tools) and module streams (nodejs:20).

Common usage

Terminal
dnf install -y git curl
dnf install -y --setopt=install_weak_deps=False vim   # skip weak deps
dnf group install -y "Development Tools"
dnf install -y https://example.com/pkg.rpm             # from a URL
dnf clean all && rm -rf /var/cache/dnf                 # shrink the image

Common errors in CI

"No match for argument: X" / "Unable to find a match" means the package name is wrong or its repo is not enabled (e.g. EPEL not added). "GPG check FAILED" / "Public key for X.rpm is not installed" means the repo key was not imported - add the repo properly or pass --nogpgcheck only for trusted local rpms. "Failed to download metadata for repo" is a network/mirror issue; retry with --setopt=retries=3. Use install_weak_deps=False to keep images slim.

Options

FlagWhat it does
-y / --assumeyesAssume yes (required in CI)
--setopt=install_weak_deps=FalseSkip weak (recommended) deps
--enablerepo / --disablerepoToggle a repo for this run
--nogpgcheckSkip GPG verification (trusted local rpms only)
group installInstall a package group

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →