Sudo apt-get 错误:/var/lib/dpkg/status 上的 flAbsPath 失败 - 没有此文件或目录

Sudo apt-get 错误:/var/lib/dpkg/status 上的 flAbsPath 失败 - 没有此文件或目录
sudo apt-get install vlc
Reading package lists... Error!
E: flAbsPath on /var/lib/dpkg/status failed - realpath (2: No such file or directory)
E: Could not open file  - open (2: No such file or directory)
E: Problem opening 
E: The package lists or status file could not be parsed or opened.

每当我尝试安装任何软件时都会出现此错误。我该如何解决这个问题?

答案1

我最近在使用 ubuntu 16.04.3 LTS 时遇到了类似的问题,我采用的方法如下 -

首先,您需要创建一个空文件,如下所示:-

adminuser@sandbox:~$ sudo touch /var/lib/dpkg/status

现在运行更新和升级:-

adminuser@sandbox:~$ sudo apt update && sudo apt upgrade

你可能最终会看到类似这样的情况——

adminuser@sandbox:~$ sudo apt update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.

adminuser@sandbox:~$ apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

但如果你注销并重新登录,你的 MOTD 将显示一些更新正在等待处理 -

Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

108 packages can be updated.
27 updates are security updates.

此时,您需要运行 dist-upgrade -

adminuser@sandbox:~$ sudo apt dist-upgrade

这应该可以解决问题,但请确保它不会迫使您升级 Ubuntu 到新版本。据我所知,在 Ubuntu 18.04 LTS 发布之前,这应该可以正常工作。祝你好运

答案2

步骤 1:cd /

第 2 步:cd var/lib/

步骤 3:mkdir dpkg

步骤 4:触摸状态

这对我有用。:)

答案3

sudo mkdir -p /var/lib/dpkg/{alternatives,info,parts,triggers,updates}

你仍然需要复制这个文件

sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status

apt-get download dpkg
sudo dpkg -i dpkg*.deb
apt-get download base-files
sudo dpkg -i base-files*.deb
sudo apt-get update
sudo apt-get check

答案4

您必须重新创建 /var/lib/dpkg 文件结构,这确实需要备份或运气(也可能两者兼而有之)。请参阅这里

相关内容