puppetlabs/puppet · error · Puppet::Error

Unable to get information about package %{name} because of:

Error message

Unable to get information about package %{name} because of: %{errmsg}

What it means

The Solaris sun provider's info2hash parses 'pkginfo -l [-d device] <name>' output; when parsing yields zero records ('No message') or a single record carrying an ERROR stanza, it raises Puppet::Error embedding that pkginfo error text. Normal execution failures are rescued into {ensure: :absent} - this error fires only when pkginfo 'succeeds' but reports an error in its payload, most often for a bad -d device when computing latest.

Source

Thrown at lib/puppet/provider/package/sun.rb:82

  # Get info on a package, optionally specifying a device.
  def info2hash(device = nil)
    args = ['-l']
    args << '-d' << device if device
    args << @resource[:name]
    begin
      pkgs = self.class.parse_pkginfo(pkginfo(*args))
      errmsg = case pkgs.size
               when 0
                 'No message'
               when 1
                 pkgs[0]['ERROR']
               end
      return self.class.namemap(pkgs[0]) if errmsg.nil?

      # according to commit 41356a7 some errors do not raise an exception
      # so even though pkginfo passed, we have to check the actual output
      raise Puppet::Error, _("Unable to get information about package %{name} because of: %{errmsg}") % { name: @resource[:name], errmsg: errmsg }
    rescue Puppet::ExecutionFailure
      { :ensure => :absent }
    end
  end

  # Retrieve the version from the current package file.
  def latest
    info2hash(@resource[:source])[:ensure]
  end

  def query
    info2hash
  end

  # only looking for -G now
  def install
    # TRANSLATORS Sun refers to the company name, do not translate
    raise Puppet::Error, _("Sun packages must specify a package source") unless @resource[:source]

View on GitHub (pinned to e227c27540)

Solutions

  1. Run exactly what the provider runs: 'pkginfo -l -d <source> <name>' and read the ERROR text echoed in %{errmsg}
  2. Fix source to a valid package datastream file or spool directory the package actually resides in
  3. List source contents with 'pkginfo -d <source>' (no name) to confirm the PKGINST spelling
  4. For ensure => latest confirm the source carries a newer VERSION than installed

Example fix

// before - source directory does not contain the package stream
package { 'SUNWfoo':
  ensure   => latest,
  provider => sun,
  source   => '/export/pkgs',
}
// after - point at the datastream file itself
package { 'SUNWfoo':
  ensure   => latest,
  provider => sun,
  source   => '/export/pkgs/SUNWfoo-1.0.pkg',
}
Defensive patterns

Strategy: try-catch

Validate before calling

# Ruby: check pkginfo can read the source device before asking for latest
def pkginfo_source_readable?(name, device)
  out = Puppet::Util::Execution.execute(['/usr/bin/pkginfo', '-l', '-d', device, name], failonfail: false).to_s
  out !~ /ERROR:/ && !out.strip.empty?
end

Try / catch

begin
  info = provider.info2hash(resource[:source])
rescue Puppet::Error => e
  raise unless e.message =~ /Unable to get information about package/
  Puppet.err("pkginfo reported: #{e.message}")
  info = { ensure: :absent }
end

Prevention

When it happens

Trigger: ensure => latest (latest calls info2hash(@resource[:source]) with -d <source>) where the source device path is wrong, not a valid package datastream/spool, or the package name is not PKGINST inside it; pkginfo writes ERROR lines while exiting 0 (commit 41356a7 behavior).

Common situations: source pointing at a directory that lacks the package stream; corrupt .pkg files; stale NFS mounts; Solaris 10 sparse zones with inherited /var/sadm.

Related errors


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