Troubleshooting "Failed to fetch package.deb 404 Not Found"

Problem

When installing packages using apt-get on Ubuntu or Debian-based Docker images, you receive a 404 error indicating the package cannot be fetched. This occurs because the package lists in CircleCI convenience images become outdated over time, causing apt to look for packages at URLs that no longer exist.

Example error message:

E: Failed to fetch http://...../package.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Solutions

Update Package Lists Before Installing

Run sudo apt-get update before any apt-get install commands to refresh the package lists:

- run:
    name: Update package lists
    command: sudo apt-get update

- run:
    name: Install packages
    command: sudo apt-get install -y package-name

This updates the local package index with the latest available packages from Ubuntu repositories.

Verify Package Name and Availability

Ensure the package name is correct, and the package is available for your Ubuntu version. Some common naming differences include:

  • Docker's package is called docker.io, not docker
  • VS Code's package is called code, not vscode
  • Check for typos in package names or version numbers

Use Current CircleCI Convenience Images

Next-generation CircleCI images (prefixed with cimg/) are rebuilt regularly and have more up-to-date package lists. Consider upgrading to a newer image version:

docker:
  - image: cimg/base:2024.12  # Current next-gen image

Outcome

After running sudo apt-get update, your package installation commands should complete successfully without 404 errors. The updated package lists will point to valid repository URLs for downloading packages.

Additional Notes

  • CircleCI convenience images are built with package lists from the build date, which can become outdated
  • Always run apt-get update before apt-get install in your jobs
  • Next-generation images (cimg/) are recommended over legacy images
  • Not all packages are available for all Ubuntu versions

Additional Resources

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

Comments

0 comments

Article is closed for comments.