{"record":{"id":"95ca774433e4fd81","repo":"puppetlabs/puppet","slug":"could-not-find-package-name-95ca77","errorCode":null,"errorMessage":"Could not find package %{name}","messagePattern":"Could not find package %(.+?)","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/yum.rb","lineNumber":323,"sourceCode":"          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)\n    if upd.nil?\n      # Yum didn't find updates, pretend the current version is the latest\n      debug \"Yum didn't find updates, current version (#{properties[:ensure]}) is the latest\"\n      version = properties[:ensure]\n      raise Puppet::DevError, _(\"Tried to get latest on a missing package\") if version == :absent || version == :purged\n","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/yum.rb#L305-L341","documentation":"When a specific version was requested (should is set), the yum provider re-queries rpm after install; a nil query means the package still is not installed and it raises Puppet::Error 'Could not find package'. Distinct from the output-scan error: yum's output looked fine ('No package ... available.' not seen) yet nothing matching is installed - typically a virtual/provides name or a transaction that silently skipped work.","triggerScenarios":"ensure => <version> where the resource name is a provides-style alias that yum resolves to a real package while 'rpm -q <name>' finds nothing; install_options like --skip-broken letting yum skip the transaction; excludes via disableexcludes hiding the result.","commonSituations":"Managing virtual names ('mysql', 'webserver', file paths); --skip-broken options copied from runbooks; version-range ensures on el7; names whose owning package differs across releases.","solutions":["After the failure run 'rpm -q <name>'; if empty, manage the real owning package name instead of the alias","Remove --skip-broken style install_options so failed transactions raise instead of skipping silently","Set allow_virtual => true on the resource so query falls back to rpm --whatprovides","Check repo exclude= lines and disableexcludes - the package may install under a different name or be filtered"],"exampleFix":"// before - 'mysql' is a virtual provides; community-mysql installs, then rpm -q mysql is empty\npackage { 'mysql':\n  ensure => '5.5.60-1.el7',\n}\n// after - real package name plus virtual-aware queries\npackage { 'community-mysql':\n  ensure        => '5.5.60-1.el7',\n  allow_virtual => true,\n}","handlingStrategy":"validation","validationCode":"# Ruby: ensure rpm will be able to see the name after yum resolves it\ndef queryable_after_install?(name, allow_virtual = false)\n  cmd = ['rpm', '-q', name]\n  cmd << '--whatprovides' if allow_virtual\n  Puppet::Util::Execution.execute(cmd, failonfail: false).exitstatus.zero? || allow_virtual\nend","typeGuard":"# Heuristic: names rpm indexes indirectly (file paths, provides aliases) need virtual queries\ndef likely_virtual_name?(name)\n  name.start_with?('/')\nend","tryCatchPattern":"begin\n  provider.install\nrescue Puppet::Error => e\n  raise unless e.message =~ /Could not find package/\n  raise Puppet::Error, \"#{resource[:name]} looks virtual - manage the real package name or set allow_virtual => true\"\nend","preventionTips":["Prefer real package names over provides aliases in manifests","Never pass --skip-broken via install_options; it hides failed transactions","Set allow_virtual => true deliberately when managing virtual package names"],"tags":["yum","virtual-packages","post-install-check","package-not-found","rhel"],"backgroundTag":"package-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}