我正在运行命令sudo apt install mongodb-org
。然后出现了这些错误。
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)
我正在使用 Ubuntu 20.04。
输出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
输出apt-cache policy debconf
debconf:
Installed: (none)
Candidate: 1.5.73
Version table:
1.5.73 500
500 http://in.archive.ubuntu.com/ubuntu focal/main amd64 Packages
答案1
您的系统已严重损坏。以下是在低级别上修复此情况的可能方法:
# 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}')
最后使用以下命令安装所有软件包:
sudo apt-get dist-upgrade
sudo apt-get install mongodb-org