YUM/DNF ignores packages from a custom repository

Recently, I needed to compile a custom version of libvirt, repack it and insert it into my own repository. YUM/DNF was however ignoring my version and continued installing one from AppStream…

I could not even see my packages running yum search libvirt, which initially led me to believe I made an error while creating the repository.

After spending many hours troubleshooting this infuriating issue, I finally found out that I can make it go away if I issue yum module disable virt

To learn why, we need to dig into the documention of dnf. There is a little known “feature” of dnf called “package filtering”:

Without modules, packages with the highest version are used by default.

Module streams can distribute packages with lower versions than available in the repositories available to the operating system. To make such packages available for installs and upgrades, the non-modular packages are filtered out when their name or provide matches against a modular package name from any enabled, default, or dependent stream. Modular source packages will not cause non-modular binary packages to be filtered out.

Source: https://dnf.readthedocs.io/en/latest/modularity.html

In other words, if there are packages of the same name from multiple repositories, they are ignored to the extent they won’t even show up in package search, as long as a package of the same name exists in an AppStream module.

I have tried several solutions, one of which was include excludepkgs=libvirt* in the AppStream repository configuration. That unfortunately resulted in having no libvirt in any repository at all. Definitely not something that I would expect to happen.

Per this RedHat bug report, it’s a “NOTABUG”, but rather a feature. That seems a bit weird to me, but does not really solve my issue.


In the end, after more time spent Googling and experimenting, I finally found a solution, which I hereby present to you. It is quite simple, I just needed to add these lines to my custom repository in /etc/yum.repos.d:

priority = 1
module_hotfixes = 1

or, to automate it in Ansible:

- name: Add a custom repository
    name: CustomRepo
    description: CustomRepo
    baseurl: https://example.com/
    enabled: yes
    priority: 1

- name: Fix custom repository
    path: /etc/yum.repos.d/CustomRepo.repo
    insertafter: 'priority'
    regexp: '^module_hotfixes'
    line: 'module_hotfixes = 1'

Ultimately, while the solution itself was quite simple, I am left annoyed and with a bitter taste of dnf.


Add yours

  1. 13 days to find this article and solve my problem.
    fucking thank you

  2. Exactly what i was looking for! thanks!!!!

  3. So, I had a bit of a different problem, but your solution was still invaluable. Thank you!

    Using Amazon Linux (based off of Fedora, but dumber in a lot of ways). AWS does version syntax much different than Fedora. So, I had to go in and hard-code the OS version in the repo file (/etc/dnf/yum.repos.d) to point to the proper Fedora version (just picked the latest and it appeared to work OK).

Leave a Reply...