Fix RPM Failed Dependencies on Install and Remove

Deepak Prasad
Tested on RHEL 10.2 (Coughlan) — vm1.lab.example
Package rpm 4.19.1.1-23.el10.x86_64
dnf 4.20.0-22.el10_2
Applies to RHEL, Rocky Linux, AlmaLinux, Oracle Linux, CentOS Stream, and Fedora with DNF or YUM-style package management
Privilege sudo or root
Scope Fix error: Failed dependencies on rpm install and erase with dnf install and dnf remove, list requirements with dnf repoquery, and install offline RPM bundles. Does not cover building custom RPMs or mirroring full repositories.
Related guides Download RPM with all dependencies
Complete RPM dependency list
Local offline DNF repository
DNF command
Install EPEL

error: Failed dependencies from rpm means a Requires rule is not satisfied — on install because a prerequisite package is missing, on erase because another installed package still depends on what you tried to remove. On RHEL family hosts the fix is usually dnf, not installing or erasing RPMs one file at a time.

This guide is RHEL family only (RHEL, Rocky Linux, AlmaLinux, Fedora, and related RPM distributions). Examples use gcc-c++ and libstdc++-devel on vm1.lab.example — reversible packages you can remove when you finish testing.

IMPORTANT
Prefer dnf install ./package.rpm on connected hosts and dnf install ./*.rpm (or a local repo) for offline bundles. Reserve rpm --nodeps for throwaway lab RPMs only.

What RPM Failed dependencies means

Command Typical error What it means
rpm -ivh package.rpm X is needed by package A Requires package is not installed yet
rpm -e package X is needed by (installed) other-package Another installed RPM still Requires the package you tried to erase

rpm reports the immediate problem and stops. DNF reads repository metadata, orders a transaction, and can install or remove multiple packages together.


Fix Failed dependencies when installing an RPM

On a connected host, point DNF at the local RPM file and let it pull missing dependencies from enabled repositories:

bash
sudo dnf install ./gcc-c++-*.rpm

Sample output (trimmed):

output
Installing:
 gcc-c++-14.3.1-4.4.el10.x86_64
Installing dependencies:
 libstdc++-devel-14.3.1-4.4.el10.x86_64

Complete!

That is the default fix when repositories work. DNF downloaded libstdc++-devel, satisfied the Requires chain, and installed both packages.

The same missing dependency is what rpm -ivh reports as libstdc++-devel = … is needed by gcc-c++-… — use dnf install ./package.rpm instead of installing dependency RPMs one file at a time.


Find missing dependencies

Before you copy RPMs to an air-gapped server, inspect what a package needs.

Direct resolved requirements

This lists packages that directly satisfy what gcc-c++ Requires — not every transitive dependency:

bash
dnf repoquery --requires gcc-c++ --resolve

Sample output:

output
gcc-0:14.3.1-4.4.el10.x86_64
glibc-0:2.39-128.el10_2.x86_64
gmp-1:6.2.1-12.el10.x86_64
libmpc-0:1.3.1-7.el10.x86_64
libstdc++-0:14.3.1-4.4.el10.x86_64
libstdc++-devel-0:14.3.1-4.4.el10.x86_64
libzstd-0:1.5.5-9.el10.x86_64
mpfr-0:4.2.1-8.el10.x86_64
zlib-ng-compat-0:2.2.3-3.el10_1.x86_64

Many entries may already be installed on the target. Use this view to see immediate gaps, not a full offline bundle list.

Recursive required dependencies

To recursively follow the package's Requires dependencies and their providers, add --recursive:

bash
dnf repoquery --requires gcc-c++ --resolve --recursive

On vm1.lab.example that query returned hundreds of packages (for example bash, coreutils, and binutils deep in the chain), while the direct query above listed nine resolved providers — useful when planning an offline bundle, though it still reflects required dependencies rather than every optional or weak dependency. For more listing tools and edge cases, see complete RPM dependency list.

Download everything you need with dnf download --resolve --alldeps as described in download RPM with all dependencies.


Install RPMs with dependencies offline

On a connected download host, pull the dependency tree into one directory:

bash
mkdir -p ~/rpm-lab/failed-deps && cd ~/rpm-lab/failed-deps
dnf download --resolve --alldeps --downloaddir=. gcc-c++

Copy that directory to the disconnected target. Red Hat documents that when repositories cannot supply dependencies, DNF must receive paths to the dependency RPMs as well — not only the top-level package file.

Install the whole bundle from the directory:

bash
cd /path/to/rpm-bundle
sudo dnf install ./*.rpm

DNF reads every RPM in the glob, resolves Requires across the set, and installs the transaction. Pointing it at ./package.rpm alone does not automatically pull in sibling RPM files sitting in the same folder.

Alternatively, run createrepo on the directory, add a file:// entry under /etc/yum.repos.d/, and install with dnf install package-name from that local repository — see local offline DNF repository.


Fix Failed dependencies when removing an RPM

rpm -e stops when another installed package still Requires what you tried to erase. After gcc-c++ and libstdc++-devel are installed, this fails:

bash
rpm -e libstdc++-devel

Sample output:

output
error: Failed dependencies:
	libstdc++-devel = 14.3.1-4.4.el10 is needed by (installed) gcc-c++-14.3.1-4.4.el10.x86_64

Use dnf remove when you intend to uninstall a package and anything that depends on it. Preview the transaction without applying it:

bash
dnf remove --assumeno libstdc++-devel

Sample output:

output
Removing:
 libstdc++-devel
Removing dependent packages:
 gcc-c++

Transaction Summary
Remove  2 Packages
Operation aborted.

--assumeno prints the full plan and exits. A single rpm -e error line only named the first reverse dependency; DNF calculated the dependent removal chain.

When the preview looks correct, remove the same starting package and let DNF include dependents in the transaction:

bash
sudo dnf remove libstdc++-devel

DNF prompts for confirmation and lists gcc-c++ among the packages to erase — you do not need to name every dependent package yourself. On production software, read that summary carefully; removing one library RPM can pull a long chain if you picked the wrong starting package.


Why you should avoid --nodeps

Older guides suggest rpm -e package --nodeps to ignore reverse dependencies. That drops the RPM database entry while other packages still expect those files on disk — a common path to a broken system.

This walkthrough never used --nodeps on gcc-c++, libstdc++-devel, or any RHEL platform package. Treat --nodeps as a last resort on custom or lab-only RPMs you built yourself, not on packages from BaseOS, AppStream, or EPEL.


Troubleshooting

Symptom Likely cause Fix
rpm -ivh lists one missing package, then another on retry Manual one-by-one installs Use dnf install ./package.rpm on connected hosts
Offline dnf install ./foo.rpm still fails Dependency RPMs sit in the directory but were not passed to DNF Run sudo dnf install ./*.rpm or configure a local offline repository
dnf install ./foo.rpm fails with nothing provides on a connected host Disabled repo, wrong architecture, or EPEL missing Enable required repos; match OS major version and CPU arch to the RPM
rpm -e shows Failed dependencies Another installed RPM still Requires this package Use dnf remove package and read the planned transaction
dnf remove wants to erase many system packages Starting package is deep in the dependency graph Cancel, preview with --assumeno, or stop using the software instead of forcing removal
Bundle still incomplete after download Used --resolve without --alldeps or wrong OS on download host Re-download with dnf download --resolve --alldeps on a host matching the offline target

References


Summary

error: Failed dependencies means RPM's Requires rules are not met. On RHEL family systems, fix install errors with dnf install ./package.rpm when repositories work, or with sudo dnf install ./*.rpm (or a local repo) when dependencies exist only as files in an offline bundle — not by pointing DNF at the main RPM alone.

To plan that bundle, use dnf repoquery --requires --resolve for direct requirements and --recursive when you need the recursive Requires chain. For removal, rpm -e shows the first blocker; dnf remove package previews and executes the dependent chain — start from one package name, read the transaction, and avoid rpm --nodeps on platform software.


Frequently Asked Questions

1. Why does rpm -ivh show Failed dependencies?

rpm checks whether the package requirements are satisfied, but it does not search enabled repositories and download missing dependencies for you. If a required capability is unavailable from the installed system or RPMs supplied in the same transaction, it stops with Failed dependencies.

2. Should I use rpm --nodeps to fix Failed dependencies?

No for normal system packages. --nodeps bypasses dependency checks and can leave broken RPM metadata or remove packages other software still needs. Prefer dnf install for local RPMs, or dnf remove when uninstalling. Use --nodeps only on disposable lab packages you fully understand.

3. What is the difference between rpm -e and dnf remove for dependencies?

rpm -e reports packages that still Require the RPM you asked to erase. dnf remove plans a transaction and can remove dependent packages too, which is why its list is often longer than a single rpm -e error line.

4. How do I install a local RPM with all dependencies on RHEL?

On a connected host, run dnf install ./package.rpm so DNF pulls missing Requires packages from enabled repositories. For offline targets, download the tree with dnf download --resolve --alldeps, copy the directory, then run sudo dnf install ./*.rpm or configure that directory as a local repository — pointing DNF at only the main RPM file does not automatically consume every other RPM in the folder.

5. Does this apply to Ubuntu or Debian?

No. This workflow is for RPM-based RHEL family distributions and Fedora. Debian and Ubuntu use DEB packages and apt, not rpm and dnf.
Omer Cakmak

Linux Administrator

Highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware.

  • Debian
  • Ubuntu
  • Linux
  • Red Hat Enterprise Linux
  • Shell Script
  • System Administration