I was running the command sudo apt install mongodb-org. And I got these errors.
E: Cannot get debconf version. Is debconf installed? debconf: apt-extracttemplates failed: No such file or directory Extracting templates from packages: 31%E: Cannot get debconf version. Is debconf installed? debconf: apt-extracttemplates failed: No such file or directory Extracting templates from packages: 63%E: Cannot get debconf version. Is debconf installed? debconf: apt-extracttemplates failed: No such file or directory Extracting templates from packages: 94%E: Cannot get debconf version. Is debconf installed? debconf: apt-extracttemplates failed: No such file or directory Extracting templates from packages: 100% dpkg: error: unable to create new file '/var/lib/dpkg/info/format-new': No such file or directory E: Sub-process /usr/bin/dpkg returned an error code (2) I am using Ubuntu 20.04.
Output of ls -ls /var/lib/dpkg/info/{,format-new} | head -n2
ls: cannot access '/var/lib/dpkg/info/': No such file or directory ls: cannot access '/var/lib/dpkg/info/format-new': No such file or directory Output of apt-cache policy debconf
debconf: Installed: (none) Candidate: 1.5.73 Version table: 1.5.73 500 500 focal/main amd64 Packages 21 Answer
You have severe damage of your system. Below is the possible way to fix this situation on low level:
# create missed dpkg info directory sudo mkdir /var/lib/dpkg/info/ # create missed dpkg alternatives directory sudo mkdir /var/lib/dpkg/alternatives # recreate other directories as well sudo mkdir /var/lib/dpkg/{parts,triggers,updates} # update package lists sudo apt-get update # install missed debconf package sudo apt-get install debconf # reinstall all currently installed packages to correctly fill /var/lib/dpkg/info/ sudo apt-get install --reinstall $(dpkg -l | grep ^ii | awk '{print $2}') And finally install whatever packages with commands like:
sudo apt-get dist-upgrade sudo apt-get install mongodb-org 3