The dpkg available file is missing or corrupted, preventing package installations. This file tracks available packages from repositories and can be rebuilt by merging package lists from apt.
The `/var/lib/dpkg/available` file is dpkg's database of packages available for installation from your configured repositories. When this file is missing or unreadable, dpkg cannot proceed with package operations. This typically occurs after accidental deletion, system corruption, or incomplete package management operations. While dpkg uses this file internally, apt-based systems maintain their own package cache, so the file can be safely reconstructed from repository data.
Run the following commands to remove the corrupted available file and reconstruct it from your apt repositories:
sudo dpkg --clear-avail
for i in /var/lib/apt/lists/*_Packages; do sudo dpkg --merge-avail "$i"; doneThe --clear-avail option erases the existing available file, and --merge-avail rebuilds it by reading the Packages lists from your configured repositories.
After rebuilding the available file, refresh your package lists to ensure everything is current:
sudo apt-get updateThis synchronizes your local package database with the latest information from your repositories.
Confirm the file was successfully created and is readable:
ls -la /var/lib/dpkg/available
file /var/lib/dpkg/availableThe file should exist and be readable by the dpkg process.
Try a simple package query to verify dpkg is working correctly:
sudo apt-cache search bash
sudo apt-get install -s nanoThe -s flag simulates an installation without actually installing, letting you verify dpkg functionality.
If the above steps don't work, your dpkg status database may also be corrupted. Check /var/lib/dpkg/status and verify it's readable with file /var/lib/dpkg/status. If both files are missing, you can restore from backup: sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status. For systems using dselect (older systems), the available file is more critical, but modern apt-based systems primarily use dpkg's status file. In severe corruption cases, you may need to boot from a live USB and repair the system from there.
dpkg: serious warning: files list file for package 'package-name' contains empty filename
How to fix "files list file contains empty filename" in APT
E: Sub-process /usr/bin/dpkg returned an error code (2)
How to fix "Sub-process /usr/bin/dpkg returned an error code (2)" in APT
dpkg-divert: error: rename involves overwriting 'path' with different file
How to fix dpkg-divert rename conflicts in APT
E: Sub-process /usr/bin/dpkg returned an error code (1) during kernel installation
How to fix "dpkg returned an error code (1)" in APT kernel installation
dpkg: dependency problems prevent configuration of triggers
dpkg: dependency problems prevent configuration of triggers in apt