Skip to content
Search Rocky Linux

    Browse this documentation

    Conflicting repositories: --enablerepo, includepkgs and cost (Rocky 9, tested)

    dnf installs a package from a repo you did not expect, or two repos both offer the same name and you want to pin the source. On Rocky 9 there are three groups of tools: temporarily toggling repos, filtering inside a repo definition, and cost weighting. The third one did not behave as documented in this test — the page says so below.

    Terminal window
    sudo dnf --disablerepo="*" --enablerepo=multi list available
    Available Packages
    libpsl.aarch64 0.21.1-5.el9 multi
    publicsuffix-list-dafsa.noarch 20210518-3.el9 multi
    tree.aarch64 1.8.0-10.el9 multi
    wget.aarch64 1.21.1-11.el9_8 multi

    --disablerepo="*" turns everything off first, then --enablerepo= enables the one you trust — the most predictable approach, and it only applies to that command, so a risky repo is never left permanently enabled.

    Option two: filter packages in the repo definition

    Section titled “Option two: filter packages in the repo definition”
    [multi]
    name=Multi
    baseurl=file:///srv/multi
    enabled=1
    gpgcheck=0
    includepkgs=tree
    Available Packages
    tree.aarch64 1.8.0-10.el9 multi

    includepkgs=tree makes the repo expose only tree; every other package (including wget and its dependencies) becomes invisible.

    The inverse uses excludepkgs:

    excludepkgs=wget
    Available Packages
    libpsl.aarch64 0.21.1-5.el9 multi
    publicsuffix-list-dafsa.noarch 20210518-3.el9 multi
    tree.aarch64 1.8.0-10.el9 multi

    wget disappears from the list; the other three remain.

    Option three: cost — it did not work in this test

    Section titled “Option three: cost — it did not work in this test”

    Two local repos provide the same rpm, with cost=10 and cost=20; repoquery --location shows which one dnf would use:

    Terminal window
    sudo dnf --disablerepo="*" --enablerepo=A,B repoquery --location tree
    file:///srv/repoB/tree-1.8.0-10.el9.aarch64.rpm

    Swapping the costs (A=99, B=1) and running again still resolved to repoB. In other words, cost did not change the selection in this scenario.

    Conclusion: do not treat cost as a reliable cross-repo priority mechanism. When you must pin a source, name it with --enablerepo or exclude the unwanted source with excludepkgs.

    • Permanently enabling a third-party repo (enabled=1): a later dnf update may replace system packages with third-party builds; prefer --enablerepo for one command;
    • includepkgs takes package names, not file names: write tree, not tree-1.8.0-10.el9.aarch64;
    • Editing a repo file without dnf clean all: the metadata cache still applies and list available appears unchanged.

    Practice: install only from the repo you choose

    Section titled “Practice: install only from the repo you choose”

    Prerequisite: Rocky 9 with a local repo built as in Offline package installs.

    Terminal window
    sudo dnf --disablerepo="*" --enablerepo=multi install -y tree

    Checks:

    1. dnf --disablerepo="*" --enablerepo=multi list available | grep -c tree → 1
    2. Add includepkgs=tree to /etc/yum.repos.d/multi.repo, run dnf clean all, repeat step 1 → wget no longer appears
    3. Replace with excludepkgs=wget (remove includepkgs) → wget is absent from the list