Fix Rocky 9 dnf "Error: Unable to find a match"
Rocky 9 dnf "Error: Unable to find a match" means no enabled repo has that name. Check EPEL, CRB, command names, and excludes with repolist and provides.
No match for argument: htopError: Unable to find a match: htopNone of the enabled repositories has a package by that name. On Rocky 9, packages missing from the default repos (BaseOS, AppStream, Extras) are usually in EPEL or CRB; otherwise you typed a command name or an exclude hides the package. The line just above the error tells you which.
[1] List the repositories. If only three are enabled, you have neither EPEL nor CRB.
# dnf repolist --allrepo id repo name statusappstream Rocky Linux 9 - AppStream enabledbaseos Rocky Linux 9 - BaseOS enabledcrb Rocky Linux 9 - CRB disabledextras Rocky Linux 9 - Extras enabled(Disabled debug/source lines are trimmed.) crb ships with Rocky but is disabled by default.
[2] Install EPEL for common tools such as htop. epel-release lives in the Extras repo, so it installs right away. On first install, the package itself recommends enabling CRB too:
# rpm -q --scripts epel-releasepostinstall scriptlet (using /bin/sh):# Doing a check to see if crb is enabled is as hard and resource intense as enabling or disabling crb.# So we will say crb is recommended, without first checking. But only on the initial install.if [ "$1" -eq 1 ] ; then echo "Many EPEL packages require the CodeReady Builder (CRB) repository." echo "It is recommended that you run /usr/bin/crb enable to enable the CRB repository."fi# dnf -y install epel-release# dnf -y install htop# rpm -q htophtop-3.3.0-1.el9.x86_64[3] Look in CRB for build tools and development headers. ninja-build fails the same way until CRB is enabled.
# dnf -y install ninja-buildNo match for argument: ninja-buildError: Unable to find a match: ninja-build# dnf -q repoquery --disablerepo="*" --enablerepo=crb ninja-build 2>&1 | head -2ninja-build-0:1.10.2-6.el9.x86_64A one-off --enablerepo=crb searches the repo without enabling it. To keep using it, enable it. Minimal installs and containers lack config-manager, so install dnf-plugins-core first (epel-release already pulls it in, and the crb enable the package suggests also works).
# dnf -y -q install dnf-plugins-core && dnf config-manager --set-enabled crb && dnf repolist | grep -i crbcrb Rocky Linux 9 - CRB# dnf -y -q install ninja-build && rpm -q ninja-buildninja-build-1.10.2-6.el9.x86_64To revert, run dnf config-manager --set-disabled crb.
[4] Check whether you typed a command name. ifconfig is a command; the package is net-tools. Give dnf provides a file path to find the package, opening the front with */.
# dnf -y install ifconfigNo match for argument: ifconfigError: Unable to find a match: ifconfig# dnf -q provides "*/ifconfig"net-tools-2.0-0.64.20160912git.el9.x86_64 : Basic networking toolsRepo : baseosMatched from:Filename : /usr/sbin/ifconfigNames are case-sensitive too (dnf install HTOP fails the same way even with EPEL enabled).
[5] If the name is right and it still fails, look for an exclude. The line above the error reads differently in that case.
# dnf -y --exclude=nano install nanoAll matches were filtered out by exclude filtering for argument: nanoError: Unable to find a match: nanoLook for an exclude= line in /etc/dnf/dnf.conf, or excludepkgs=/includepkgs= in the repo files (/etc/yum.repos.d/*.repo). Below, exclude=nano was added to dnf.conf. The file and line tell you whether it is main (dnf.conf) or a single repository.
# grep -rn -e '^exclude' -e '^excludepkgs' -e '^includepkgs' /etc/dnf/dnf.conf /etc/yum.repos.d//etc/dnf/dnf.conf:7:exclude=nanoIf you have confirmed the install is fine, lift the restriction only where it applies and preview the transaction with --assumeno (it installs nothing). --disableexcludes takes main (dnf.conf), a repository ID, or all, and according to the docs it disables includepkgs as well as excludes (dnf command reference). all lifts every repository's restrictions and can change dependencies too, so name only the place the grep pointed to.
# dnf --disableexcludes=main --assumeno install nano 2>&1 | grep -E '^(Installing|Install|Upgrade|Operation)| nano 'Installing: nano x86_64 5.6.1-7.el9 baseos 691 kInstall 1 PackageInstalled size: 2.7 MOperation aborted.If the list holds only the package you intended, run the same command without --assumeno. If Upgrading: or other packages show up, do not install.
If the repository itself is unreachable, the message becomes Failed to download metadata; see dnf Failed to download metadata. After installing, check what needs a restart with dnf needs-restarting.