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.


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
    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.