Problem
After adding the HashiCorp RPM repository on a Red Hat Enterprise Linux (RHEL) system using the yum-config-manager command, you may encounter a 404 - Not Found error when trying to update your package lists.
To add the repository, you run the following command:
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Afterward, an update may fail with an error similar to this:
https://rpm.releases.hashicorp.com/RHEL/7Server/x86_64/stable/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Cause
This error occurs due to a mismatch in the $releasever variable used by yum. The HashiCorp RPM repository URL expects a simple number for the release version (e.g., 7 or 8). However, some RHEL-based platforms set this variable to a more specific string, such as 7Server, which results in an invalid URL and a 404 error.
Solution
To resolve this issue, you must edit the repository configuration file to replace the dynamic $releasever variable with the static major version number of your RHEL release.
-
Open the repository file located at
/etc/yum.repos.d/hashicorp.repoin a text editor or use a command-line tool likesedto perform the replacement. The following command replaces$releaseverwith7. Adjust the number to match your RHEL version if it is different.$ sudo sed -i -e "s/\$releasever/7/g" "/etc/yum.repos.d/hashicorp.repo"
-
After modifying the file, clear the
yumcache and update your repository data.$ sudo yum clean all $ sudo yum makecache
Outcome
With the correct release version in the repository URL, yum can now successfully fetch the repository metadata, allowing you to install or update HashiCorp packages.