{"record":{"id":"3d822ef2749c64d1","repo":"puppetlabs/puppet","slug":"could-not-find-package-name-3d822e","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/ports.rb","lineNumber":22,"sourceCode":"  desc \"Support for FreeBSD's ports.  Note that this, too, mixes packages and ports.\"\n\n  commands :portupgrade => \"/usr/local/sbin/portupgrade\",\n           :portversion => \"/usr/local/sbin/portversion\",\n           :portuninstall => \"/usr/local/sbin/pkg_deinstall\",\n           :portinfo => \"/usr/sbin/pkg_info\"\n\n  %w[INTERACTIVE UNAME].each do |var|\n    ENV.delete(var) if ENV.include?(var)\n  end\n\n  def install\n    # -N: install if the package is missing, otherwise upgrade\n    # -M: yes, we're a batch, so don't ask any questions\n    cmd = %w[-N -M BATCH=yes] << @resource[:name]\n\n    output = portupgrade(*cmd)\n    if output =~ /\\*\\* No such /\n      raise Puppet::ExecutionFailure, _(\"Could not find package %{name}\") % { name: @resource[:name] }\n    end\n  end\n\n  # If there are multiple packages, we only use the last one\n  def latest\n    cmd = [\"-v\", @resource[:name]]\n\n    begin\n      output = portversion(*cmd)\n    rescue Puppet::ExecutionFailure => e\n      raise Puppet::Error.new(output, e)\n    end\n    line = output.split(\"\\n\").pop\n\n    unless line =~ /^(\\S+)\\s+(\\S)\\s+(.+)$/\n      # There's no \"latest\" version, so just return a placeholder\n      return :latest\n    end","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/ports.rb#L4-L40","documentation":"Raised in `install` (lib/puppet/provider/package/ports.rb:22) of Puppet's FreeBSD ports provider. It runs `portupgrade -N -M BATCH=yes <name>` and greps the output for portupgrade's `** No such ` marker; when found it converts that into Puppet::ExecutionFailure 'Could not find package', since portupgrade reports an unknown port/portorigin only in its text output.","triggerScenarios":"A package title that names no known port or origin: typos, using a pkg-plist name instead of the port origin, a ports tree that lacks the port, or a stale INDEX after ports moved.","commonSituations":"Ports renamed/moved (see /usr/ports/UPDATING and MOVED); portsnap not run so the tree is old; manifests written with binary package names instead of `category/port` origins.","solutions":["Find the correct origin: `whereis <name>` or `make -C /usr/ports search name=<name>`.","Use the origin form `mail/postfix` in the resource title when the bare name fails.","Update the ports tree (`portsnap fetch update`) and rerun the agent.","If the port was moved, update the manifest to its new location per UPDATING."],"exampleFix":"# before\npackage { 'postfix':\n  ensure   => installed,\n  provider => ports,\n}\n\n# after - use the port origin\npackage { 'mail/postfix':\n  ensure   => installed,\n  provider => ports,\n}","handlingStrategy":"validation","validationCode":"# Confirm the port origin exists before declaring the resource\nwhereis -q \"${name}\" | grep -q . || make -C /usr/ports search name=\"${name}\" >/dev/null || echo \"no such port - fix the title to category/port\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use port origins (`mail/postfix`) as resource titles with the ports provider.","Keep portsnap current so origins match reality.","Track /usr/ports/UPDATING and MOVED for renamed ports."],"tags":["freebsd","ports","portupgrade","package-not-found"],"backgroundTag":"package-not-found-in-repo","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}