dpkg: error: failed to open package info file `/var/lib/dpkg/available' for reading
I get the following error after installing nmap:
dpkg: error: failed to open package info file `/var/lib/dpkg/available' for reading: No such file or directory
E: Sub-process /usr/bin/dpkg returned an error code (2)
Solution 1:
Missing available file
My available and available-old was both empty.
I've successfully resolved from this by running:
cat /var/lib/apt/lists/*_Packages >/var/lib/dpkg/available
dpkg --configure -a
Or using sudo
cat /var/lib/apt/lists/*_Packages | sudo dd of=/var/lib/dpkg/available
sudo dpkg --configure -a
Solution 2:
Open a terminal(Ctrl+Alt+t) and type the following, one line at a time:
sudo dpkg --configure -a
sudo apt-get -f install
sudo apt-get --fix-missing install
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get clean
sudo apt-get autoremove
This should repair/recreate your /var/lib/dpkg/available
file.
(Source)
Solution 3:
dpkg: error: failed to open package info file `/var/lib/dpkg/available' for reading: No such file or directory
The above error clearly shows that the file available
in the directory /var/lib/dpkg
is missing. Don't worry about that. There will be a backup for all the files inside /var/lib/dpkg
directory is located on the same directory itself. So just renaming or copying the backup file would solve your problem.
sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
This will create a new file called available
on the same directory. Please note that dpkg
will only look for the file /var/lib/dpkg/available
and not /var/lib/dpkg/available-old
.