puppetlabs/puppet · error · Puppet::Error
You must specify a package source or configure an installpat
Error message
You must specify a package source or configure an installpath in /etc/pkg.conf
What it means
openbsd.rb:147 (parse_pkgconf): the stricter sibling of the 'no valid installpath' error — it fires when the resource has no source and /etc/pkg.conf does not exist at all. Without either a per-resource source or an installpath file, pkg_add has no idea where to fetch packages from, so the provider refuses with Puppet::Error.
Source
Thrown at lib/puppet/provider/package/openbsd.rb:147
@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
e_vars = {}
full_name = @resource[:source]
end
View on GitHub (pinned to e227c27540)
Solutions
- Create /etc/pkg.conf with an installpath line (via a file resource that runs before packages).
- Alternatively set source per package (directory URL ending in '/' so the code sets PKG_PATH), e.g. source => 'https://ftp.openbsd.org/pub/OpenBSD/7.4/packages/amd64/'.
- Order the pkg.conf creation explicitly with before/require so parse_pkgconf finds the file on the first run.
Example fix
# before
package { 'rsync--': ensure => installed } # /etc/pkg.conf missing
# after
file { '/etc/pkg.conf': ensure => file, content => 'installpath = https://ftp.openbsd.org/pub/OpenBSD/7.4/packages/%a\n', before => Package['rsync--'] }
package { 'rsync--': ensure => installed } Defensive patterns
Strategy: validation
Validate before calling
# no source and no pkg.conf -> will raise; check first
has_conf = Puppet::FileSystem.exist?('/etc/pkg.conf')
raise 'OpenBSD needs package source or /etc/pkg.conf installpath' if resource[:source].nil? && !has_conf Try / catch
begin
provider.send(:parse_pkgconf)
rescue Puppet::Error => e
raise unless e.message.include?('installpath in /etc/pkg.conf')
# first run: create pkg.conf then retry
write_default_pkgconf; retry
end Prevention
- Include pkg.conf creation in base OpenBSD profiles with before => Package <| |>.
- Never prune /etc/pkg.conf in image hardening without also setting per-package sources.
- Smoke-test package installs in your OpenBSD image build.
When it happens
Trigger: ensure => installed package resource with no source on an OpenBSD node where /etc/pkg.conf has been deleted or never created (Puppet::FileSystem.exist? fails).
Common situations: Minimal/hardened OpenBSD images that prune /etc; chroots and build jails without a base etc set; first runs before any configuration management of pkg.conf.
Related errors
- No valid installpath found in /etc/pkg.conf and no source wa
- /etc/apt/sources.list contains a cdrom source; not installin
- %{version} is not available for this package
- The aix provider can only be used by root
- Could not list installed Packages: %{detail}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/114bf4b04f6d1598.
Report an issue: GitHub.