I am working on a project using Fedora Workstation 42 (x86_64) as my operating system. I created a simple script to install all my project dependencies, which utilized the official install instructions for Vagrant and Packer (verified that this issue also potenially impacts Terraform, Vault, Boundary, and Consul. My script looked something like this:
#!/usr/bin/env bash
set -euo pipefail
# <-- bunch of stuff here -->
wget -O- https://rpm.releases.hashicorp.com/fedora/hashicorp.repo | sudo tee /etc/yum.repos.d/hashicorp.repo
sudo yum list available | grep hashicorp
sudo dnf -y install packer vagrant
but the script would exit after stating “No matching packages to list” and before it could install Vagrant or Packer with dnf.
[0] Downloading ‘https://rpm.releases.hashicorp.com/fedora/hashicorp.repo’ …
[hashicorp]
name=Hashicorp Stable - $basearch
baseurl=https://rpm.releases.hashicorp.com/fedora/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpg
[hashicorp-test]
name=Hashicorp Test - $basearch
baseurl=https://rpm.releases.hashicorp.com/fedora/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://rpm.releases.hashicorp.com/gpgHTTP response 200 [https://rpm.releases.hashicorp.com/fedora/hashicorp.repo]
Updating and loading repositories:
Hashicorp Stable - x86_64 100% | 12.8 KiB/s | 1.5 KiB | 00m00s
Repositories loaded.
Metadata cache created.
Updating and loading repositories:
Repositories loaded.
No matching packages to list
After a frustrating amount of time (thinking that my architecture was somehow not supported or some sort of hashicorp outage) I found that running sudo yum list --available | grep hashicorp actually returned a list of packages. I was able to narrow it down to my use of set -e and the incorrect command provided in the instructions.
Example 1: yum list available with -e
#!/usr/bin/env bash
set -e
wget -O- https://rpm.releases.hashicorp.com/fedora/hashicorp.repo | sudo tee /etc/yum.repos.d/hashicorp.repo
sudo yum list available | grep hashicorp # Returns non-zero status
# Script exits here. No install.
sudo dnf -y install packer vagrant
Example 2: yum list --available with -euo pipefail (original)
#!/usr/bin/env bash
set -euo pipefail
wget -O- https://rpm.releases.hashicorp.com/fedora/hashicorp.repo | sudo tee /etc/yum.repos.d/hashicorp.repo
sudo yum list --available | grep hashicorp # Returns zero status
sudo dnf -y install packer vagrant
# Script exits here. Install successful.
From what I can tell, Yum/Dnf5 are looking for an installed package called “available” which does not exist and therefore returns a non-zero exit status.
$ sudo yum list --help
Usage:
dnf5 [GLOBAL OPTIONS] list [OPTIONS] [ARGUMENTS]
Options:
--showduplicates Show all versions of the packages, not only the latest
ones.
--installed-from-repo=REPO Filters installed packages by the ID of the repository
D,... they were installed from.
--installed List installed packages.
--available List available packages.
--extras List extras, that is packages installed on the system
that are not available in any known repository.
--obsoletes List packages installed on the system that are obsolet
ed by packages in any known repository.
--recent List packages recently added into the repositories.
--upgrades List upgrades available for the installed packages.
--autoremove List packages which will be removed by the 'dnf autore
move' command.
--updates Alias for '--upgrades'
Arguments:
package-spec-NI List of package-spec-NI to match (case insensitively)
$ sudo yum list packer
Updating and loading repositories:
Repositories loaded.
Installed packages
packer.x86_64 1.14.3-1 hashicorp
I understand that my choice to run this in a script with set -e is what’s ultimately causing my issue, but unless I am missing something super fundamental here (very possible) then I think the install instructions for Fedora 42 should be updated to use --available. This would account for shell options in scripts (and maybe anyone who doesn’t even try to install with dnf after seeing “No matching packages to list”).