puppetlabs/puppet · error · Puppet::ExecutionFailure

Could not find package %{name}

Error message

Could not find package %{name}

What it means

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.

Source

Thrown at lib/puppet/provider/package/ports.rb:22

  desc "Support for FreeBSD's ports.  Note that this, too, mixes packages and ports."

  commands :portupgrade => "/usr/local/sbin/portupgrade",
           :portversion => "/usr/local/sbin/portversion",
           :portuninstall => "/usr/local/sbin/pkg_deinstall",
           :portinfo => "/usr/sbin/pkg_info"

  %w[INTERACTIVE UNAME].each do |var|
    ENV.delete(var) if ENV.include?(var)
  end

  def install
    # -N: install if the package is missing, otherwise upgrade
    # -M: yes, we're a batch, so don't ask any questions
    cmd = %w[-N -M BATCH=yes] << @resource[:name]

    output = portupgrade(*cmd)
    if output =~ /\*\* No such /
      raise Puppet::ExecutionFailure, _("Could not find package %{name}") % { name: @resource[:name] }
    end
  end

  # If there are multiple packages, we only use the last one
  def latest
    cmd = ["-v", @resource[:name]]

    begin
      output = portversion(*cmd)
    rescue Puppet::ExecutionFailure => e
      raise Puppet::Error.new(output, e)
    end
    line = output.split("\n").pop

    unless line =~ /^(\S+)\s+(\S)\s+(.+)$/
      # There's no "latest" version, so just return a placeholder
      return :latest
    end

View on GitHub (pinned to e227c27540)

Solutions

  1. Find the correct origin: `whereis <name>` or `make -C /usr/ports search name=<name>`.
  2. Use the origin form `mail/postfix` in the resource title when the bare name fails.
  3. Update the ports tree (`portsnap fetch update`) and rerun the agent.
  4. If the port was moved, update the manifest to its new location per UPDATING.

Example fix

# before
package { 'postfix':
  ensure   => installed,
  provider => ports,
}

# after - use the port origin
package { 'mail/postfix':
  ensure   => installed,
  provider => ports,
}
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the port origin exists before declaring the resource
whereis -q "${name}" | grep -q . || make -C /usr/ports search name="${name}" >/dev/null || echo "no such port - fix the title to category/port"

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/3d822ef2749c64d1. Report an issue: GitHub.