{"record":{"id":"a49e72386b85acc7","repo":"puppetlabs/puppet","slug":"etc-apt-sources-list-contains-a-cdrom-source-not","errorCode":null,"errorMessage":"/etc/apt/sources.list contains a cdrom source; not installing.  Use 'allowcdrom' to override this failure.","messagePattern":"/etc/apt/sources\\.list contains a cdrom source; not installing\\.  Use 'allowcdrom' to override this failure\\.","errorType":"exception","errorClass":"Puppet::Error","httpStatus":null,"severity":"error","filePath":"lib/puppet/provider/package/apt.rb","lineNumber":93,"sourceCode":"  end\n\n  # A derivative of DPKG; this is how most people actually manage\n  # Debian boxes, and the only thing that differs is that it can\n  # install packages from remote sites.\n\n  # Double negation confuses Rubocop's Layout cops\n  # rubocop:disable Layout\n  def checkforcdrom\n    have_cdrom = begin\n                   !!(File.read(\"/etc/apt/sources.list\") =~ /^[^#]*cdrom:/)\n                 rescue\n                   # This is basically pathological...\n                   false\n                 end\n  # rubocop:enable Layout\n\n    if have_cdrom and @resource[:allowcdrom] != :true\n      raise Puppet::Error, _(\"/etc/apt/sources.list contains a cdrom source; not installing.  Use 'allowcdrom' to override this failure.\")\n    end\n  end\n\n  def best_version(should_range)\n    versions = []\n\n    output = aptcache :madison, @resource[:name]\n    output.each_line do |line|\n      is = line.split('|')[1].strip\n      begin\n        is_version = DebianVersion.parse(is)\n        versions << is_version if should_range.include?(is_version)\n      rescue DebianVersion::ValidationFailure\n        Puppet.debug(\"Cannot parse #{is} as a debian version\")\n      end\n    end\n\n    return versions.max if versions.any?","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/provider/package/apt.rb#L75-L111","documentation":"The apt provider's checkforcdrom (apt.rb:93) reads /etc/apt/sources.list and, if any non-commented line contains 'cdrom:', aborts the install with Puppet::Error unless the package resource sets allowcdrom => :true. It guards against unattended installs silently prompting for a CD-ROM disc that is not present.","triggerScenarios":"Any ensure => installed/present on a package using the apt provider on a system where /etc/apt/sources.list still contains an active `deb cdrom:...` line and the resource does not set allowcdrom. The file read is wrapped in a rescue (missing file counts as no cdrom), so only the combination cdrom-line + no allowcdrom triggers it.","commonSituations":"Debian installed from CD/DVD/ISO media whose sources.list still lists the cdrom entry; offline mirror setups cloned from a media install; minimal containers based on installer images.","solutions":["Comment out or remove the `deb cdrom:...` line in /etc/apt/sources.list (usually the right fix — cdrom entries rarely belong on managed servers).","If the cdrom source is intentional, opt in per resource: `package { 'foo': ensure => installed, allowcdrom => true }`.","Replace the cdrom entry with a real network mirror and run apt-get update."],"exampleFix":"# before\n# /etc/apt/sources.list:  deb cdrom:[Debian...]/ stable main\npackage { 'htop': ensure => installed }\n\n# after (sources.list):  # deb cdrom:[Debian...]/ stable main\n#   deb http://deb.debian.org/debian stable main\npackage { 'htop': ensure => installed }","handlingStrategy":"validation","validationCode":"# fail fast with a clear message before apt runs\ncdrom = File.read('/etc/apt/sources.list') =~ /^[^#]*cdrom:/ rescue nil\nallow = resource[:allowcdrom] == :true\nraise 'cdrom source active; pass allowcdrom or fix sources.list' if cdrom && !allow","typeGuard":null,"tryCatchPattern":"begin\n  provider.install\nrescue Puppet::Error => e\n  raise unless e.message.include?('allowcdrom')\n  # retry once with explicit consent flag set\n  resource[:allowcdrom] = :true; retry\nend","preventionTips":["Manage /etc/apt/sources.list with Puppet and template out cdrom entries on servers.","In install profiles that must work from media, set allowcdrom => true deliberately.","Assert no active cdrom: lines in your image tests (grep -E '^[^#]*cdrom:' /etc/apt/sources.list)."],"tags":["puppet","apt","debian","packages","repository-config"],"backgroundTag":"package-source-misconfigured","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}