How to fix Error: Transaction check error with dnf/yum

When a dnf or yum process gets interrupted, you may get the below error:

Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction check error:
file /usr/share/doc/avahi-libs/README from install of avahi-libs-0.6.32-0.4.rc.fc23.i686 conflicts
with file from package avahi-libs-0.6.31-43.fc23.x86_64

When presented with Error: Transaction check error, you are unable to install, update, or upgrade your system. The solution is to attempt to install the program (or download the files), locate them on your system, and manually update them using rpm.

In the example above, I want to update avahi-libs to a later version, but an older version still exists on my system. The dnf process was interrupted before it could erase the older version. Hence, the error means manual intervention of the problem is required. To fix, one needs to locate the newer version and use the rpm command to forcefully install the update. In other words, do the following:

find /var/cache/dnf/ -iname avahi-libs-0.6.32* -type f
rpm -Uvh --replacefiles /path/to/avahi-libs-0.6.32-0.4.rc.fc23.i686.rpm

There is a good chance that the file you need is in /var/cache/dnf/ already and does not need to be downloaded from a mirror.