puppetlabs/puppet · error · Puppet::Error

No valid installpath found in /etc/pkg.conf and no source wa

Error message

No valid installpath found in /etc/pkg.conf and no source was set

What it means

openbsd.rb:143 (parse_pkgconf): when the package resource has no source and /etc/pkg.conf exists but contains no usable installpath (= or +=) line, the provider raises Puppet::Error. On OpenBSD, pkg_add needs PKG_PATH or a source; installpath in pkg.conf is how that is usually provided, so an empty/fragmentary pkg.conf leaves nothing to install from.

Source

Thrown at lib/puppet/provider/package/openbsd.rb:143

      if Puppet::FileSystem.exist?("/etc/pkg.conf")
        File.open("/etc/pkg.conf", "rb").readlines.each do |line|
          matchdata = line.match(/^installpath\s*=\s*(.+)\s*$/i)
          if matchdata
            @resource[:source] = matchdata[1]
          else
            matchdata = line.match(/^installpath\s*\+=\s*(.+)\s*$/i)
            if matchdata
              if @resource[:source].nil?
                @resource[:source] = matchdata[1]
              else
                @resource[:source] += ":" + matchdata[1]
              end
            end
          end
        end

        unless @resource[:source]
          raise Puppet::Error,
                _("No valid installpath found in /etc/pkg.conf and no source was set")
        end
      else
        raise Puppet::Error,
              _("You must specify a package source or configure an installpath in /etc/pkg.conf")
      end
    end
  end

  def install(latest = false)
    cmd = []

    parse_pkgconf

    if @resource[:source][-1, 1] == ::File::SEPARATOR
      e_vars = { 'PKG_PATH' => @resource[:source] }
      full_name = get_full_name(latest)
    else

View on GitHub (pinned to e227c27540)

Solutions

  1. Set installpath in /etc/pkg.conf (manage the file via Puppet's augeas/file resources), e.g. `installpath = ftp.openbsd.org/pub/OpenBSD/7.4/packages/%a`.
  2. Or give each package resource an explicit source (URL or directory ending in '/') so pkg.conf is not consulted.
  3. Keep the pkg.conf resource ordered before any Package resource that depends on it.

Example fix

# before
file { '/etc/pkg.conf': ensure => present, content => "\n" }
package { 'vim--no_x11': ensure => installed }

# after
file { '/etc/pkg.conf': ensure => present, content => "installpath = https://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(arch -s)\n", before => Package['vim--no_x11'] }
package { 'vim--no_x11': ensure => installed }
Defensive patterns

Strategy: validation

Validate before calling

# pkg.conf exists — confirm it actually yields an installpath
lines = File.readlines('/etc/pkg.conf')
has_ip = lines.any? { |l| l =~ /^installpath\s*(=|\+=)/i }
raise 'no installpath in /etc/pkg.conf; set source or fix pkg.conf' unless has_ip || resource_source_set?

Try / catch

begin
  provider.send(:parse_pkgconf)
rescue Puppet::Error => e
  raise unless e.message.include?('installpath')
  resource[:source] = 'https://ftp.openbsd.org/pub/OpenBSD/7.4/packages/%a/'; retry
end

Prevention

When it happens

Trigger: package { X: ensure => installed } on OpenBSD with no source attribute and an /etc/pkg.conf that lacks any `installpath = ...` or `installpath += ...` line (e.g. a stock file that only has other settings commented in).

Common situations: Fresh OpenBSD installs where installpath was never configured; pkg.conf edited and installpath removed; using snapshots requiring explicit paths.

Related errors


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