{"record":{"id":"ac7d3717bb0b21d6","repo":"puppetlabs/puppet","slug":"sun-packages-must-specify-a-package-source","errorCode":null,"errorMessage":"Sun packages must specify a package source","messagePattern":"Sun packages must specify a package source","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/sun.rb","lineNumber":100,"sourceCode":"      raise Puppet::Error, _(\"Unable to get information about package %{name} because of: %{errmsg}\") % { name: @resource[:name], errmsg: errmsg }\n    rescue Puppet::ExecutionFailure\n      { :ensure => :absent }\n    end\n  end\n\n  # Retrieve the version from the current package file.\n  def latest\n    info2hash(@resource[:source])[:ensure]\n  end\n\n  def query\n    info2hash\n  end\n\n  # only looking for -G now\n  def install\n    # TRANSLATORS Sun refers to the company name, do not translate\n    raise Puppet::Error, _(\"Sun packages must specify a package source\") unless @resource[:source]\n\n    options = {\n      :adminfile => @resource[:adminfile],\n      :responsefile => @resource[:responsefile],\n      :source => @resource[:source],\n      :cmd_options => @resource[:install_options]\n    }\n    pkgadd prepare_cmd(options)\n  end\n\n  def uninstall\n    pkgrm prepare_cmd(:adminfile => @resource[:adminfile])\n  end\n\n  # Remove the old package, and install the new one.  This will probably\n  # often fail.\n  def update\n    uninstall if (@property_hash[:ensure] || info2hash[:ensure]) != :absent","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/sun.rb#L82-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"Porting manifests from Linux where source is unnecessary; supplying only adminfile/responsefile; forgetting the Solaris default provider needs a source for every install.","solutions":["Add source pointing at a package datastream file, spool directory, or device: source => '/export/pkgs/SUNWpython.pkg'","Distribute the source with a file resource from puppet:/// and require it from the package","On Solaris 11+ use the pkg (IPS) provider if packages come from an IPS repository instead"],"exampleFix":"// before\npackage { 'SUNWpython':\n  ensure => installed,\n}\n// after\nfile { '/export/pkgs/SUNWpython.pkg':\n  ensure => file,\n  source => 'puppet:///modules/base/SUNWpython.pkg',\n}\npackage { 'SUNWpython':\n  ensure   => installed,\n  provider => sun,\n  source   => '/export/pkgs/SUNWpython.pkg',\n  require  => File['/export/pkgs/SUNWpython.pkg'],\n}","handlingStrategy":"validation","validationCode":"# Ruby: reject sun-provider package resources that lack a source before the run\nPuppet::Type.type(:package).validate do\n  if self[:provider].to_s == 'sun' && ![:absent, :purged].include?(self[:ensure]) && self[:source].nil?\n    raise ArgumentError, \"package '#{self[:name]}' uses the sun provider and requires a source\"\n  end\nend","typeGuard":"# True when the resource is something the sun provider can actually install\ndef sun_installable?(resource)\n  resource[:provider].to_s == 'sun' && !resource[:source].nil?\nend","tryCatchPattern":"begin\n  provider.install\nrescue Puppet::Error => e\n  raise unless e.message =~ /must specify a package source/\n  raise Puppet::Error, \"#{resource[:name]}: add source => '/path/to/pkg' (pkgadd cannot fetch from repos)\"\nend","preventionTips":["Add module spec tests asserting source is set for every Solaris package resource","Centralize package source paths in hiera so omissions are lint-visible","Use the pkg (IPS) provider on Solaris 11+ where repositories exist"],"tags":["solaris","pkgadd","missing-attribute","manifest-config","package-provider"],"backgroundTag":"missing-required-attribute","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}