Ubuntu执行apt-get install
等命令行时,出现:
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)
经查看后发现,不知道哪一次采用别人的做法,将 /var/lib/dpkg/info 文件夹误删,导致现在无该文件夹,在其他网站的大神指引下,成功修复这个bug。
具体做法:
# 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 your-package