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
  end

View on GitHub (pinned to e227c27540)

Solutions

  1. Add `source =>` pointing to the local .deb path — typically a file resource that stages it from puppet:// or a URL first.
  2. If you actually want repository installs, use the apt (or aptitude) provider instead of dpkg.
  3. 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

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


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