dpkg:不可恢复的致命错误(包的文件列表文件' java-common'缺少最终换行符)

时间:2016-09-23 15:51:13

标签: linux ubuntu apt-get dpkg

我正在尝试使用命令apt-get install ...在我的Linux操作系统上安装软件包。 问题是我收到了这个错误:

Selecting previously unselected package liberror-perl.
dpkg: unrecoverable fatal error, aborting:
 files list file for package 'java-common' is missing final newline
E: Sub-process /usr/bin/dpkg returned an error code (2)

搜索错误(甚至逐行),解决方案SEEMS将下载并安装缺少的包以解决依赖关系"因为它指出了here。问题是,当我尝试执行sudo apt-get -f install时,我会一次又一次地出现同样的错误。有什么建议吗?如果我不能使用apt-get,我该如何更改包?

3 个答案:

答案 0 :(得分:5)

我使用python脚本解决了这个问题:

#!/usr/bin/python


# 8th November, 2009
# update manager failed, giving me the error:
# 'files list file for package 'xxx' is missing final newline' for every package.
# some Googling revealed that this problem was due to corrupt files(s) in /var/lib/dpkg/info/
# looping though those files revealed that some did not have a final new line
# this script will resolve that problem by appending a newline to all files that are missing it
# NOTE: you will need to run this script as root, e.g. sudo python newline_fixer.py

import os

dpkg_path = '/var/lib/dpkg/info/'
paths = os.listdir(dpkg_path)
for path in paths:
path = dpkg_path + path
f = open(path, 'a+')
data = f.read()
if len(data) > 1 and data[-1:] != '\n':
    f.write('\n')
    print 'added newline character to:', path
f.close()  

使用命令sudo python name_script.py运行脚本后,问题得以解决:似乎某些文件已损坏。提出了解决方案here

答案 1 :(得分:0)

如果出现以下错误

dpkg:不可恢复的致命错误,正在中止: 包“java-common”的文件列表文件缺少最后的换行符 E:子进程/usr/bin/dpkg返回错误码(2)

注意:java-common 是列表名

使用以下命令解决此问题(使用您的列表名称修改 java-common)

sudo rm /var/lib/dpkg/info/java-common.list

sudo apt-get install java-common --reinstall

sudo dpkg --configure -a sudo apt 更新 sudo apt 升级

答案 2 :(得分:-1)

您必须删除丢失的文件

 sudo rm /var/lib/dpkg/info/java-common.list 

现在您可以重新安装此

 sudo apt-get install java-common --reinstall