puppetlabs/puppet · error · Puppet::Error
Could not find package %{wanted}
Error message
Could not find package %{wanted} What it means
After executing the yum install/update command, the provider scans combined output for the literal 'No package <wanted> available.' line - yum on el4/5 exits 0 in this case so output must be checked - and raises Puppet::Error. 'wanted' is the actual argument passed to yum (name, or name-version with arch reordered), so both typos and unavailable versions surface here.
Source
Thrown at lib/puppet/provider/package/yum.rb:317
operation = update_command
elsif rpm_compare_evr(should, current_package[:ensure]) < 0
debug "Downgrading package #{@resource[:name]} from version #{current_package[:ensure]} to #{should}"
operation = :downgrade
elsif rpm_compare_evr(should, current_package[:ensure]) > 0
debug "Upgrading package #{@resource[:name]} from version #{current_package[:ensure]} to #{should}"
operation = update_command
end
end
end
# Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize;
# ensure we capture output to check for errors.
no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? ["-d", "0"] : []
command = [command(:cmd)] + no_debug + ["-e", error_level, "-y", install_options, operation, wanted].compact
output = execute(command)
if output.to_s =~ /^No package #{wanted} available\.$/
raise Puppet::Error, _("Could not find package %{wanted}") % { wanted: wanted }
end
# If a version was specified, query again to see if it is a matching version
if should
is = query
raise Puppet::Error, _("Could not find package %{name}") % { name: name } unless is
version = is[:ensure]
# FIXME: Should we raise an exception even if should == :latest
# and yum updated us to a version other than @param_hash[:ensure] ?
raise Puppet::Error, _("Failed to update to version %{should}, got version %{version} instead") % { should: should, version: version } unless
insync?(version)
end
end
# What's the latest package version available?
def latest
upd = self.class.latest_package_version(@resource[:name], disablerepo, enablerepo, disableexcludes)View on GitHub (pinned to e227c27540)
Solutions
- Verify availability exactly: 'yum --showduplicates list <name>' and compare the NEVRA shown
- Fix the resource to a name/version from that listing; include the epoch when yum prints one ('1:2.0-1.el7')
- Check install_options, enablerepo/disablerepo and /etc/yum.repos.d - the repo carrying the package may be disabled
- Refresh metadata: 'yum clean expire-cache && yum makecache', then re-run the agent
Example fix
// before - pin not present in the enabled repo set
package { 'docker-ce':
ensure => '18.03.0.ce-1.el7.centos',
}
// after - version listed by 'yum --showduplicates list docker-ce' with its repo enabled
package { 'docker-ce':
ensure => '18.03.1.ce-1.el7.centos',
install_options => [{ '--enablerepo' => 'docker-ce-stable' }],
} Defensive patterns
Strategy: validation
Validate before calling
# Ruby: pre-check that yum can resolve the exact want string
def yum_package_available?(wanted)
out = Puppet::Util::Execution.execute(['yum', '-q', 'list', wanted], failonfail: false, combine: false).to_s
out !~ /No matching Packages to list|Error: No package|No package #{Regexp.escape(wanted)} available/
end Try / catch
begin
provider.install
rescue Puppet::Error => e
raise unless e.message =~ /Could not find package/
Puppet.err("run `yum --showduplicates list #{resource[:name]}` and pin to a listed version/repo")
raise
end Prevention
- Generate version pins from 'yum --showduplicates list' output in CI, including epochs
- Test role manifests against the same repo snapshot as production
- Review enablerepo/disablerepo and install_options whenever a pin starts failing
When it happens
Trigger: ensure => installed or ensure => '<version>' without source on yum where the package or pinned name-version does not exist in enabled repos - typo'd names, versions absent from base/updates, repos excluded via disablerepo or install_options, or the el4/5 exit-0 quirk.
Common situations: Pins generated for a different repo snapshot (e.g. EPEL vs base version-release strings); '--enablerepo' naming an undefined repo; arch-suffixed names; stale yum metadata.
Related errors
- Could not find package %{name}
- Failed to update to version %{should}, got version %{version
- Could not find package %{name}
- The yum provider can only be used as root
- Could not find package %{name}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/23db8e2fb2caa4ca.
Report an issue: GitHub.