“无法解析或打开软件包列表或状态文件”

“无法解析或打开软件包列表或状态文件”

每次我sudo apt-get update都无法完成,最后会说

E: Read error - read (5: Input/output error)
E: The package lists or status file could not be parsed or opened.

同样,当我尝试安装某些东西并执行sudo apt-get install <some app>

我该怎么办?我承认我的驱动器有坏扇区,这可能是原因吗?我还能做什么吗?

答案1

这是一个老问题,但仅出于存档目的...以下是解决我的问题的方法:

sudo rm /var/lib/apt/lists/* -vf
sudo apt-get clean
sudo apt-get update

答案2

尝试使用较旧的状态文件,

sudo mv /var/lib/dpkg/status /var/lib/dpkg/status.bad
sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
sudo apt-get update

答案3

我遇到了类似的错误:

Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList /var/lib/dpkg/status
E: The package lists or status file could not be parsed or opened.

我按照类似的建议进行复制status-old

$ head /var/lib/dpkg/status
$ head /var/lib/dpkg/status-old

由于某种原因,我的所有状态文件都是空白的。幸运的是,我发现这些文件有备份:

$ ls -l /var/backups/dpkg.status.*
-rw-r--r-- 1 root root 444620 Nov 15 06:33 /var/backups/dpkg.status.0
-rw-r--r-- 1 root root 444620 Nov 15 06:33 /var/backups/dpkg.status.1.gz
-rw-r--r-- 1 root root 128168 Sep 20  2013 /var/backups/dpkg.status.2.gz
-rw-r--r-- 1 root root 112545 Sep 16  2013 /var/backups/dpkg.status.3.gz
-rw-r--r-- 1 root root 107767 Sep 14  2013 /var/backups/dpkg.status.4.gz
-rw-r--r-- 1 root root 107766 Sep 11  2013 /var/backups/dpkg.status.5.gz
-rw-r--r-- 1 root root  94583 Sep 11  2013 /var/backups/dpkg.status.6.gz

我检查了最新的备份...

$ head /var/backups/dpkg.status.0

...但它仍然是空白的。所以我解压了一个旧版本...

$ gunzip /var/backups/dpkg.status.1.gz
$ head /var/backups/dpkg.status.1

这次有内容了。所以我复制了它...

$ cp /var/backups/dpkg.status.1 /var/lib/dpkg/status

然后apt-get update运行就没有问题了。

这篇文章功不可没。

答案4

我遇到了类似的错误,但问题不在于dpkg.status,而在于恰当的列表中。

要检查可能的原因,请运行strace -efile apt install something。然后查找在出现错误消息之前访问的最后文件:

stat("/var/lib/apt/lists/linux.dropbox.com_ubuntu_dists_xenial_main_i18n_Translation-en%5fUS.uncompressed", 0x7fffd2f39d00) = -1 ENOENT (No such file or directory)
stat("/var/lib/apt/lists/linux.dropbox.com_ubuntu_dists_xenial_main_i18n_Translation-en%5fUS", 0x7fffd2f39e50) = -1 ENOENT (No such file or directory)
stat("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_InRelease", 0x7fffd2f39d10) = -1 ENOENT (No such file or directory)
stat("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_Release", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_InRelease", 0x7fffd2f396d0) = -1 ENOENT (No such file or directory)
stat("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_Release", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=57344, ...}) = 0
open("/tmp/fileutl.message.XlglFW", O_RDWR|O_CREAT|O_EXCL, 0600) = 5
unlink("/tmp/fileutl.message.XlglFW")   = 0
open("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_Release", O_RDONLY) = 6
open("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_Release", O_RDONLY) = 5
stat("/var/lib/apt/lists/www.fossology.org_releases_2.6.2_Ubuntu_dists_14.04_Release", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
Reading package lists... Done
E: The package lists or status file could not be parsed or opened.
+++ exited with 100 +++

在我的例子中,最后一个文件(Release来自 fossology 的一个文件)的长度为 0 字节。删除该存储库后,apt 即可恢复正常功能

相关内容