puppetlabs/puppet · error · ArgumentError
You cannot install dpkg packages without a source
Error message
You cannot install dpkg packages without a source
What it means
The dpkg provider's install (dpkg.rb:92) raises ArgumentError when @resource[:source] is nil, because dpkg itself can only install from a local .deb file — unlike apt it has no repository resolution. The provider requires every install to carry an explicit source pointing at a staged deb.
Source
Thrown at lib/puppet/provider/package/dpkg.rb:92
if hash[:status] == 'not-installed'
hash[:ensure] = :purged
elsif %w[config-files half-installed unpacked half-configured].include?(hash[:status])
hash[:ensure] = :absent
end
hash[:mark] = hash[:desired] == 'hold' ? :hold : :none
else
Puppet.debug("Failed to match dpkg-query line #{line.inspect}")
end
hash
end
public
def install
file = @resource[:source]
unless file
raise ArgumentError, _("You cannot install dpkg packages without a source")
end
args = []
if @resource[:configfiles] == :keep
args << '--force-confold'
else
args << '--force-confnew'
end
args << '-i' << file
unhold if properties[:mark] == :hold
begin
dpkg(*args)
ensure
hold if @resource[:mark] == :hold
end
endView on GitHub (pinned to e227c27540)
Solutions
- Add `source =>` pointing to the local .deb path — typically a file resource that stages it from puppet:// or a URL first.
- If you actually want repository installs, use the apt (or aptitude) provider instead of dpkg.
- Ensure the source parameter is on the same package resource (not defined elsewhere) and is not undef.
Example fix
# before
package { 'haproxy': ensure => installed, provider => 'dpkg' }
# after
file { '/tmp/haproxy.deb': source => 'puppet:///modules/profile/haproxy.deb', before => Package['haproxy'] }
package { 'haproxy': ensure => installed, provider => 'dpkg', source => '/tmp/haproxy.deb' } Defensive patterns
Strategy: validation
Validate before calling
# in a custom function / parent class
resources.each do |r|
next unless r[:provider] == :dpkg && r[:ensure].to_s != 'absent'
raise "dpkg package #{r[:name]} needs a source" if r[:source].nil?
end Try / catch
begin
provider.install
rescue ArgumentError => e
raise unless e.message.include?('without a source')
# stage the deb then retry with source set
stage_deb(resource); resource[:source] = '/tmp/foo.deb'; retry
end Prevention
- Always pair provider => dpkg with a staging file resource and an explicit source.
- Use the apt provider when you want repository installs.
- Write a catalog lint rule: dpkg package with ensure present/installed must declare source.
When it happens
Trigger: package { X: ensure => installed, provider => dpkg } without a source attribute; also when the source is set on a separate resource (title/name mismatch) or its value evaluates to undef.
Common situations: Assuming dpkg behaves like apt and will fetch from repos; forgetting the file/staging step in a profile; templates that omit source for nodes without an internal mirror.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Package #{hash[:name]}, version #{hash[:ensure]} is in error
- /etc/apt/sources.list contains a cdrom source; not installin
- Could not find package %{name}
- Failed to update to version %{should}, got version %{version
- Could not find package %{name}
AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21).
Data as JSON: /api/errors/6302e69c98880bd6.
Report an issue: GitHub.