puppetlabs/puppet · error · Puppet::ExecutionFailure
Could not find package %{name}
Error message
Could not find package %{name} What it means
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.
Source
Thrown at lib/puppet/provider/package/portupgrade.rb:96
packages
end
######## Installation sub command
def install
Puppet.debug "portupgrade.install() - Installation call on #{@resource[:name]}"
# -M: yes, we're a batch, so don't ask any questions
cmdline = ["-M BATCH=yes", @resource[:name]]
# FIXME: it's possible that portinstall prompts for data so locks up.
begin
output = portinstall(*cmdline)
rescue Puppet::ExecutionFailure => e
raise Puppet::Error.new(output, e)
end
if output =~ /\*\* No such /
raise Puppet::ExecutionFailure, _("Could not find package %{name}") % { name: @resource[:name] }
end
# No return code required, so do nil to be clean
nil
end
######## Latest subcommand (returns the latest version available, or current version if installed is latest)
def latest
Puppet.debug "portupgrade.latest() - Latest check called on #{@resource[:name]}"
# search for latest version available, or return current version.
# cmdline = "portversion -v <portorigin>", returns "<portname> <code> <stuff>"
# or "** No matching package found: <portname>"
cmdline = ["-v", @resource[:name]]
begin
output = portversion(*cmdline)
rescue Puppet::ExecutionFailure => eView on GitHub (pinned to e227c27540)
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
Example fix
// before
package { 'postfix':
ensure => installed,
provider => portupgrade,
}
// after - full port origin as the resource name
package { 'mail/postfix':
ensure => installed,
provider => portupgrade,
} Defensive patterns
Strategy: validation
Validate before calling
# Ruby: guard before relying on the portupgrade provider
def port_origin_exists?(origin)
File.directory?("/usr/ports/#{origin}")
end Type guard
# Returns true when name is a full port origin (category/port) PORT_ORIGIN = /\A[a-z0-9-]+\/[a-z0-9_-]+\z/ def port_origin?(name) name.is_a?(String) && PORT_ORIGIN.match?(name) end
Try / catch
begin
provider.install
rescue Puppet::ExecutionFailure => e
raise Puppet::Error, "portinstall could not resolve #{resource[:name]} - use the full port origin" if e.message =~ /Could not find package/
raise
end Prevention
- 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
When it happens
Trigger: 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 '.
Common situations: Using the short package name instead of <category>/<port>; stale ports tree where the port moved or was removed; typos in the origin string.
Related errors
- Could not find package %{name}
- Unexpected output from portversion: %{output}
- Could not find package %{name}
- urn.inspect
- No package found with the specified name [%{name}]
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/fa497f58ef33033c.
Report an issue: GitHub.