puppetlabs/puppet · error · Puppet::Error

Sun packages must specify a package source

Error message

Sun packages must specify a package source

What it means

The sun provider's install refuses to run without a source attribute: unlike yum-style providers there is no repository concept, pkgadd needs a device or datastream. The error is raised up-front before pkgadd executes whenever a package resource using provider sun (the default on Solaris) omits source.

Source

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

      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]

    options = {
      :adminfile => @resource[:adminfile],
      :responsefile => @resource[:responsefile],
      :source => @resource[:source],
      :cmd_options => @resource[:install_options]
    }
    pkgadd prepare_cmd(options)
  end

  def uninstall
    pkgrm prepare_cmd(:adminfile => @resource[:adminfile])
  end

  # Remove the old package, and install the new one.  This will probably
  # often fail.
  def update
    uninstall if (@property_hash[:ensure] || info2hash[:ensure]) != :absent

View on GitHub (pinned to e227c27540)

Solutions

  1. Add source pointing at a package datastream file, spool directory, or device: source => '/export/pkgs/SUNWpython.pkg'
  2. Distribute the source with a file resource from puppet:/// and require it from the package
  3. On Solaris 11+ use the pkg (IPS) provider if packages come from an IPS repository instead

Example fix

// before
package { 'SUNWpython':
  ensure => installed,
}
// after
file { '/export/pkgs/SUNWpython.pkg':
  ensure => file,
  source => 'puppet:///modules/base/SUNWpython.pkg',
}
package { 'SUNWpython':
  ensure   => installed,
  provider => sun,
  source   => '/export/pkgs/SUNWpython.pkg',
  require  => File['/export/pkgs/SUNWpython.pkg'],
}
Defensive patterns

Strategy: validation

Validate before calling

# Ruby: reject sun-provider package resources that lack a source before the run
Puppet::Type.type(:package).validate do
  if self[:provider].to_s == 'sun' && ![:absent, :purged].include?(self[:ensure]) && self[:source].nil?
    raise ArgumentError, "package '#{self[:name]}' uses the sun provider and requires a source"
  end
end

Type guard

# True when the resource is something the sun provider can actually install
def sun_installable?(resource)
  resource[:provider].to_s == 'sun' && !resource[:source].nil?
end

Try / catch

begin
  provider.install
rescue Puppet::Error => e
  raise unless e.message =~ /must specify a package source/
  raise Puppet::Error, "#{resource[:name]}: add source => '/path/to/pkg' (pkgadd cannot fetch from repos)"
end

Prevention

When it happens

Trigger: package { 'SUNWxyz': ensure => installed } on Solaris, where sun is defaultfor os.family solaris, with no source => attribute. The guard at lib/puppet/provider/package/sun.rb:100 fires as soon as the package needs installing.

Common situations: Porting manifests from Linux where source is unnecessary; supplying only adminfile/responsefile; forgetting the Solaris default provider needs a source for every install.

Related errors


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