{"record":{"id":"fa497f58ef33033c","repo":"puppetlabs/puppet","slug":"could-not-find-package-name-fa497f","errorCode":null,"errorMessage":"Could not find package %{name}","messagePattern":"Could not find package %(.+?)","errorType":"exception","errorClass":"Puppet::ExecutionFailure","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/portupgrade.rb","lineNumber":96,"sourceCode":"    packages\n  end\n\n  ######## Installation sub command\n\n  def install\n    Puppet.debug \"portupgrade.install() - Installation call on #{@resource[:name]}\"\n    # -M: yes, we're a batch, so don't ask any questions\n    cmdline = [\"-M BATCH=yes\", @resource[:name]]\n\n    # FIXME: it's possible that portinstall prompts for data so locks up.\n    begin\n      output = portinstall(*cmdline)\n    rescue Puppet::ExecutionFailure => e\n      raise Puppet::Error.new(output, e)\n    end\n\n    if output =~ /\\*\\* No such /\n      raise Puppet::ExecutionFailure, _(\"Could not find package %{name}\") % { name: @resource[:name] }\n    end\n\n    # No return code required, so do nil to be clean\n    nil\n  end\n\n  ######## Latest subcommand (returns the latest version available, or current version if installed is latest)\n\n  def latest\n    Puppet.debug \"portupgrade.latest() - Latest check called on #{@resource[:name]}\"\n    # search for latest version available, or return current version.\n    # cmdline = \"portversion -v <portorigin>\", returns \"<portname> <code> <stuff>\"\n    # or \"** No matching package found: <portname>\"\n    cmdline = [\"-v\", @resource[:name]]\n\n    begin\n      output = portversion(*cmdline)\n    rescue Puppet::ExecutionFailure => e","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/portupgrade.rb#L78-L114","documentation":"The FreeBSD portupgrade provider raises this Puppet::ExecutionFailure from install when portinstall output contains '** No such ' - the command could not resolve the resource name to an installable port. This provider requires the port's full origin (e.g. 'mail/postfix'), not the short package name.","triggerScenarios":"package { 'postfix': provider => portupgrade, ensure => installed } where the name lacks the category/origin path; or the origin no longer exists after a ports tree update/rename (MOVED entries not honored). install() at lib/puppet/provider/package/portupgrade.rb:95 scans portinstall output for '** No such '.","commonSituations":"Using the short package name instead of <category>/<port>; stale ports tree where the port moved or was removed; typos in the origin string.","solutions":["Set the resource name to the full port origin, e.g. package { 'mail/postfix': ... }","Verify the origin exists: 'ls /usr/ports/mail/postfix' or check /usr/ports/MOVED for renames","Update the ports tree ('portsnap fetch update') and retry the agent run","On modern FreeBSD use the pkgng provider instead of portupgrade"],"exampleFix":"// before\npackage { 'postfix':\n  ensure   => installed,\n  provider => portupgrade,\n}\n// after - full port origin as the resource name\npackage { 'mail/postfix':\n  ensure   => installed,\n  provider => portupgrade,\n}","handlingStrategy":"validation","validationCode":"# Ruby: guard before relying on the portupgrade provider\ndef port_origin_exists?(origin)\n  File.directory?(\"/usr/ports/#{origin}\")\nend","typeGuard":"# Returns true when name is a full port origin (category/port)\nPORT_ORIGIN = /\\A[a-z0-9-]+\\/[a-z0-9_-]+\\z/\ndef port_origin?(name)\n  name.is_a?(String) && PORT_ORIGIN.match?(name)\nend","tryCatchPattern":"begin\n  provider.install\nrescue Puppet::ExecutionFailure => e\n  raise Puppet::Error, \"portinstall could not resolve #{resource[:name]} - use the full port origin\" if e.message =~ /Could not find package/\n  raise\nend","preventionTips":["Always use full <category>/<port> origins as resource names for the portupgrade provider","Validate origins against /usr/ports (or the MOVED file) in module spec tests","Keep the ports tree fresh so renamed ports are caught before the run"],"tags":["freebsd","portupgrade","portinstall","package-not-found","port-origin"],"backgroundTag":"package-not-found","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}