3

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)
1
  • 1
    Try installing zenmap from the software centre it will automatically install nmap
    – Sudheer
    May 8 '14 at 5:53
4

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)

2
  • 1
    Show de bola!!!
    – Redbob
    Dec 1 '17 at 21:03
  • 1
    Did not work for me. Jun 4 '20 at 4:43
3

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
2
  • Did not work for me, though this is an interesting answer. Jun 4 '20 at 4:43
  • This worked for me, which is ok, since I’m only working in a throwaway environment, with this problem.
    – Smar
    Jul 24 '20 at 6:25
2
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.

2
  • and you should mention re-configuring or re-installing nmap as sudo dpkg --configure -a or sudo apt install --reinstall nmap after the above operation :) Sep 15 '17 at 17:00
  • Did not work for me. Jun 4 '20 at 4:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.