“E:子进程/usr/bin/dpkg返回错误码(1)”是什么意思?

Bra*_*iam 31 dpkg apt

每当有人在安装、升级或删除某些软件时遇到问题时,我都会多次看到此消息,但我想知道,这意味着什么,更重要的是,是否有可能解决?

(Reading database ... 81657 files and directories currently installed.)
 Removing mongodb-10gen ...
 arg: remove
 invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
 dpkg: error processing mongodb-10gen (--remove):
  subprocess installed pre-removal script returned error exit status 100
 invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
 dpkg: error while cleaning up:
  subprocess installed post-installation script returned error exit status 100
 Errors were encountered while processing:
  mongodb-10gen
 E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

(以上只是一个例子,不是我的实际问题)

Bra*_*iam 30

该消息是通用的。这只是意味着/dpkg调用的实例由于某种原因失败了。它没有解释原因、方法或提示如何解决它。作为诊断消息,它没有用。aptapt-get

您需要阅读消息之前的行(有时是相当多的行)以找到阻止您完成安装的真正错误。

是的,但我该如何解决呢?

没有单一的方法可以解决它。发生这种情况的原因有很多,试图在一个帖子中列出所有这些是徒劳的。每种情况对于该包/环境来说几乎都是独一无二的。

但是,有救赎。您看到此消息的事实意味着消息之前的行中可能有更多相关信息。出于说明目的,我将使用一个示例:

(Reading database ... 81657 files and directories currently installed.)
 Removing mongodb-10gen ...
 arg: remove
 invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
 dpkg: error processing mongodb-10gen (--remove):
  subprocess installed pre-removal script returned error exit status 100
 invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
 dpkg: error while cleaning up:
  subprocess installed post-installation script returned error exit status 100
 Errors were encountered while processing:
  mongodb-10gen
 E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

现在,要找到问题,您需要向后阅读:

  • E: Sub-process /usr/bin/dpkg returned an error code (1)没有告诉我任何有用的东西。所以继续前进。

  • Errors were encountered while processing: mongodb-10gen只是告诉我哪个包有问题。有用但还不够。

  • subprocess installed post-installation script returned error exit status 100:这告诉我失败的脚本是在postinst安装后执行的脚本。这在某些情况下会派上用场,但在这种情况下则不然。

  • dpkg: error while cleaning up: 这里没有任何用处。

  • invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.答对了!这告诉我们,invoke-rc.d在大多数类似 Debian 的系统中控制 init 脚本的二进制文件失败了。它失败了,因为它找不到/etc/init.d/mongodb脚本。这不好。我们需要创建它或从其他地方复制它,以便它再次开始工作。重新安装软件包通常也是file not found出错的一种选择。

    在这种情况下,报告错误是没有必要的,因为很可能我们是删除脚本的人,但是如果您完全确定您没有触及该文件(debsums -sla应该确认它),然后报告错误。

那么,您究竟需要什么来获得帮助?理想情况下,问题的完整输出。这也有利于包括输出sudo dpkg -Csudo apt-get check和输出apt-cache policy package1 package2...的包,其中“包1包2 ......”包括所有有问题的。