{"record":{"id":"6302e69c98880bd6","repo":"puppetlabs/puppet","slug":"you-cannot-install-dpkg-packages-without-a-source","errorCode":null,"errorMessage":"You cannot install dpkg packages without a source","messagePattern":"You cannot install dpkg packages without a source","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/dpkg.rb","lineNumber":92,"sourceCode":"      if hash[:status] == 'not-installed'\n        hash[:ensure] = :purged\n      elsif %w[config-files half-installed unpacked half-configured].include?(hash[:status])\n        hash[:ensure] = :absent\n      end\n      hash[:mark] = hash[:desired] == 'hold' ? :hold : :none\n    else\n      Puppet.debug(\"Failed to match dpkg-query line #{line.inspect}\")\n    end\n\n    hash\n  end\n\n  public\n\n  def install\n    file = @resource[:source]\n    unless file\n      raise ArgumentError, _(\"You cannot install dpkg packages without a source\")\n    end\n\n    args = []\n\n    if @resource[:configfiles] == :keep\n      args << '--force-confold'\n    else\n      args << '--force-confnew'\n    end\n    args << '-i' << file\n\n    unhold if properties[:mark] == :hold\n    begin\n      dpkg(*args)\n    ensure\n      hold if @resource[:mark] == :hold\n    end\n  end","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/dpkg.rb#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\npackage { 'haproxy': ensure => installed, provider => 'dpkg' }\n\n# after\nfile { '/tmp/haproxy.deb': source => 'puppet:///modules/profile/haproxy.deb', before => Package['haproxy'] }\npackage { 'haproxy': ensure => installed, provider => 'dpkg', source => '/tmp/haproxy.deb' }","handlingStrategy":"validation","validationCode":"# in a custom function / parent class\nresources.each do |r|\n  next unless r[:provider] == :dpkg && r[:ensure].to_s != 'absent'\n  raise \"dpkg package #{r[:name]} needs a source\" if r[:source].nil?\nend","typeGuard":null,"tryCatchPattern":"begin\n  provider.install\nrescue ArgumentError => e\n  raise unless e.message.include?('without a source')\n  # stage the deb then retry with source set\n  stage_deb(resource); resource[:source] = '/tmp/foo.deb'; retry\nend","preventionTips":["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."],"tags":["puppet","dpkg","debian","packages","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}