{"record":{"id":"23db8e2fb2caa4ca","repo":"puppetlabs/puppet","slug":"could-not-find-package-wanted","errorCode":null,"errorMessage":"Could not find package %{wanted}","messagePattern":"Could not find package %(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/yum.rb","lineNumber":317,"sourceCode":"          operation = update_command\n        elsif rpm_compare_evr(should, current_package[:ensure]) < 0\n          debug \"Downgrading package #{@resource[:name]} from version #{current_package[:ensure]} to #{should}\"\n          operation = :downgrade\n        elsif rpm_compare_evr(should, current_package[:ensure]) > 0\n          debug \"Upgrading package #{@resource[:name]} from version #{current_package[:ensure]} to #{should}\"\n          operation = update_command\n        end\n      end\n    end\n\n    # Yum on el-4 and el-5 returns exit status 0 when trying to install a package it doesn't recognize;\n    # ensure we capture output to check for errors.\n    no_debug = Puppet.runtime[:facter].value('os.release.major').to_i > 5 ? [\"-d\", \"0\"] : []\n    command = [command(:cmd)] + no_debug + [\"-e\", error_level, \"-y\", install_options, operation, wanted].compact\n    output = execute(command)\n\n    if output.to_s =~ /^No package #{wanted} available\\.$/\n      raise Puppet::Error, _(\"Could not find package %{wanted}\") % { wanted: wanted }\n    end\n\n    # If a version was specified, query again to see if it is a matching version\n    if should\n      is = query\n      raise Puppet::Error, _(\"Could not find package %{name}\") % { name: name } unless is\n\n      version = is[:ensure]\n      # FIXME: Should we raise an exception even if should == :latest\n      # and yum updated us to a version other than @param_hash[:ensure] ?\n      raise Puppet::Error, _(\"Failed to update to version %{should}, got version %{version} instead\") % { should: should, version: version } unless\n        insync?(version)\n    end\n  end\n\n  # What's the latest package version available?\n  def latest\n    upd = self.class.latest_package_version(@resource[:name], disablerepo, enablerepo, disableexcludes)","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/yum.rb#L299-L335","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before - pin not present in the enabled repo set\npackage { 'docker-ce':\n  ensure => '18.03.0.ce-1.el7.centos',\n}\n// after - version listed by 'yum --showduplicates list docker-ce' with its repo enabled\npackage { 'docker-ce':\n  ensure          => '18.03.1.ce-1.el7.centos',\n  install_options => [{ '--enablerepo' => 'docker-ce-stable' }],\n}","handlingStrategy":"validation","validationCode":"# Ruby: pre-check that yum can resolve the exact want string\ndef yum_package_available?(wanted)\n  out = Puppet::Util::Execution.execute(['yum', '-q', 'list', wanted], failonfail: false, combine: false).to_s\n  out !~ /No matching Packages to list|Error: No package|No package #{Regexp.escape(wanted)} available/\nend","typeGuard":null,"tryCatchPattern":"begin\n  provider.install\nrescue Puppet::Error => e\n  raise unless e.message =~ /Could not find package/\n  Puppet.err(\"run `yum --showduplicates list #{resource[:name]}` and pin to a listed version/repo\")\n  raise\nend","preventionTips":["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"],"tags":["yum","package-not-found","version-pin","repositories","rhel"],"backgroundTag":"package-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}