MongoDB 安装错误 /E: 子进程 /usr/bin/dpkg 返回错误代码 (1)

MongoDB 安装错误 /E: 子进程 /usr/bin/dpkg 返回错误代码 (1)

我正在尝试在 Linux(Crunchbang Linux - Debian 的衍生版本)中安装东西,但我收到了指向 mongodb-20gen 的错误。

当我尝试使用以下命令删除它时:-

  cometbill@Linuxn00b:~$ sudo apt-get remove mongodb-10gen

我得到...

 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following packages will be REMOVED:
   mongodb-10gen
 0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
 1 not fully installed or removed.
 After this operation, 221 MB disk space will be freed.
 Do you want to continue [Y/n]? y
(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)

我在这里读到了有关 MongoDB 的类似错误的内容,它建议删除 mongo-clients,所以,我尝试了:-

 cometbill@Linuxn00b:~$ sudo apt-get remove mongodb-clients

并得到:-

 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 Package 'mongodb-clients' is not installed, so not removed
 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
 1 not fully installed or removed.
 After this operation, 0 B of additional disk space will be used.
 Setting up mongodb-10gen (2.4.6) ...
 invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
 dpkg: error processing mongodb-10gen (--configure):
 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)

根据 schaiba 的建议,我尝试了:-

cometbill@Linuxn00b:~$ sudo apt-get install -f

并得到:-

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up mongodb-10gen (2.4.6) ...
invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found.
dpkg: error processing mongodb-10gen (--configure):
 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)

答案1

由于错误消息抱怨/etc/init.d/mongodb不存在,请尝试创建该文件。这可能足以在这种情况下取​​得进展。

一般来说,当安装或删除脚本失败时,请查看/var/lib/dpkg/info/$PACKAGE.{preinst,postinst,prerm,postrm}.如果它是 shell 脚本,请set -x在该行下方添加#!以使其打印跟踪。如果需要更正错误,请编辑脚本,然后运行apt-get -f install

答案2

这个 AskUbuntu 帖子为我解决了问题;我编辑/var/lib/dpkg/status并删除了导致问题的部分。

相关内容