Build Fails Using 'apt-get update' Command

Debian Stretch (Debian 9)

We’re starting to see reports of CircleCI builds failing due to an error when running apt-get update. The problem we’re tracking is due to the Debian repository for Debian Stretch (Debian 9) removing the backports component of their repository.

The error:

    Could not open file /var/lib/apt/lists/deb.debian.org_debian_dists_stretch-backports_main_binary-amd64_Packages.diff_Index
    - open (2: No such file or directory)

Affected Images

We’re seeing images have this issue that are:

  1. based on Debian 9 (Stretch)
  2. older images (last built more than 90 days ago)


There are a few solutions you can take for your project depending on which works best for you:

  1. Use an image tag that updates the primary version of your software. For example, an image we know affected is circleci/ruby:2.6.5-stretch-node-browsers. This contains Ruby v2.6.5 which is fairly old. Newer patch releases, such as Ruby v2.6.6 are not affected by this issue.
  2. Use a newer base OS. Using the same affected image as an example, circleci/ruby:2.6.5-stretch-node-browsers, this image uses Debian 9 (Stretch) as a base, which is 3+ years old. Removing the string stretch will use a newer Debian or Ubuntu base, which is unaffected by this issue. For example, you could use circleci/ruby:2.6.5-node-browsers.
  3. Use a next-gen Convenience Image. The next-gen Convenience Images aren’t affected by this issue as they’re all Ubuntu 18.04 or Ubuntu 20.04 based.
  4. You can patch this issue without changing the image by deleting the Apt cache before running sudo apt-get update. This would look like this:
- run: |
    sudo rm -rf /var/lib/apt/lists/*
    sudo apt-get update


Additional Resources:

Was this article helpful?
7 out of 11 found this helpful



Article is closed for comments.