Two RHEL 9.4 systems; one produces 404 errors for EPEL repositories

I’m installing epel-release in two different RHEL 9.4-based containers:

yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %{rhel}).noarch.rpm

One is based on:

$ grep ^VERSION /etc/os-release
VERSION="9.20241104.0.4 (Plow)"
VERSION_ID=9.4

And the other is based on:

$ grep ^VERSION /etc/os-release
VERSION="9.20241008.0.4 (Plow)" 
VERSION_ID=9.4

In the 9.20241008.0.4 variant, this works fine:

bash-5.1# yum --disablerepo=\* --enablerepo=epel makecache
[...]
Extra Packages for Enterprise Linux 9 - x86_64                                                                119 kB/s |  35 kB     00:00
Metadata cache created.

But on the 9.20241104.0.4 version, accessing EPEL fails with a 404 error:

bash-5.1# yum --disablerepo=\* --enablerepo=epel makecache
[...]
Extra Packages for Enterprise Linux 9.4 - x86_64                                                               83 kB/s | 144 kB     00:01
Errors during downloading metadata for repository 'epel':
  - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-9.4&arch=x86_64&infra=$infra&content=$contentdir (IP: 152.19.134.198)
  - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-9.4&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.21)
  - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-9.4&arch=x86_64&infra=$infra&content=$contentdir&countme=1 (IP: 8.43.85.67)
  - Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-9.4&arch=x86_64&infra=$infra&content=$contentdir (IP: 8.43.85.67)
Error: Failed to download metadata for repo 'epel': Cannot prepare internal mirrorlist: Status code: 404 for https://mirrors.fedoraproject.org/metalink?repo=epel-9.4&arch=x86_64&infra=$infra&content=$contentdir (IP: 38.145.60.21)

In the second instance, $releasever is being replaced by 9.4, which causes a 404 error (which is itself probably also a problem, since RHEL 9.4 has been out since April and 9.3, 9.2, and 9.1 work as expected).

Where does the value of releasever come from, and how do I see it? This answer from unix.stackexhange.com suggests:

/usr/libexec/platform-python -c '
import dnf, json
db = dnf.dnf.Base()
print(json.dumps(db.conf.substitutions, indent=2))'

Which produces identical output in both environments:

{
  "arch": "x86_64",
  "basearch": "x86_64",
  "releasever": "9"
}

Given the about output, where is that 9.4 coming from?

(As a workaround, I’m simply running sed -i "s/\\\$releasever/$(rpm -E '%{rhel}')/g" /etc/yum.repos.d/*.repo, which works fine, but I’m curious why this is necessary.)

It took some puttering through the dnf source, but I finally figured it out.

The 9.20241104.0.4 variant has:

bash-5.1# cat /etc/dnf/vars/releasever
9.4

Whereas the other variant does not have this file.

The sample code presented in that other answer was incorrect; it needs to call the ...conf.subsitutions.update_from_etc() method before printing out the values, like this:

/usr/libexec/platform-python -c '
import dnf, json
db = dnf.dnf.Base()
db.conf.substitutions.update_from_etc("/")
print(json.dumps(db.conf.substitutions, indent=2))'

Which will produce:

{
  "arch": "x86_64",
  "basearch": "x86_64",
  "releasever": "9.4"
}
1 Like

There’s actually a pending update for epel-release that should help with this. It changes the repo definition from releasever to a literal 9.

https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2024-51d6bfef87

It was created in response to this bug report, where Azure users also have releasever set to something other than just 9.

https://bugzilla.redhat.com/show_bug.cgi?id=2219796

You should also be aware that the EPEL 9 repo only targets compatibility with the current minor version of RHEL 9, which is 9.5 at the moment. Many packages will work fine, but at some point you may run into installation issues when pinning to older minor versions like this. If you must stick with 9.4 for whatever reason, but still need EPEL packages, I recommend changing your configuration to point to the archive snapshot of 9.4.

https://dl.fedoraproject.org/pub/archive/epel/9.4/

There is some ongoing work to have MirrorManager automatically direct you to archive mirrors if you ask for specific minor verisons, but it’s still a work in progress as not all minor versions are functional yet.

https://pagure.io/fedora-infrastructure/issue/11968