Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've seen this message several times whenever someone has a problem installing, upgrading or removing some piece of software, but I wonder, what does it mean, and more importantly, is possible to solve it?

(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)

(the above is just an example, not my actual problem)

share|improve this question
    
If you tried apt-get install (something) and you got this error message like I did, the solution for me was apt-get upgrade (something). –  PJ Brunet Feb 3 at 18:57

1 Answer 1

up vote 17 down vote accepted

That message is generic. It just means that the dpkg instance called by apt/apt-get failed for some reason. It doesn't explain why, how, or give hints how to solve it. As a diagnostic message, it is not useful.

You need to read the lines before the message (sometimes quite a number of them) to find the real error that prevents you from completing the installation.

Yeah, but how do I solve it?

There is no single way to solve it. There are so many reasons why this can happen that it's futile to attempt to list them all in a single post. Each and every circumstance is almost unique to that package/environment.

But, there's redemption. The fact that you see this message means that probably there is more relevant information in the lines before the message. For illustrative purposes I will use a example:

(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)

Now, to find the problem, you need to read backwards:

  • E: Sub-process /usr/bin/dpkg returned an error code (1) doesn't tell me anything useful. So moving on.
  • Errors were encountered while processing: mongodb-10gen just tells me what package have problems. Is useful but not enough.
  • subprocess installed post-installation script returned error exit status 100: this tells me that the script that failed was the postinst, the one executed in post-installation. This will come handy in some situations, but not in this one.
  • dpkg: error while cleaning up: nothing useful here.
  • invoke-rc.d: unknown initscript, /etc/init.d/mongodb not found. BINGO! This tells us that invoke-rc.d, a binary that controls the init script in most Debian-like system, failed. It failed because it couldn't find the /etc/init.d/mongodb script. This is bad. We need to create it or copy from somewhere else so it starts working again. Reinstalling the package is also normally an option for file not found errors.

    In this case, reporting a bug is not necessary because is probable that we were the ones that removed the script, but if you are completely sure you didn't touch the file (a debsums -sla should confirm it) then report a bug.

So, what exactly do you need to get help? Ideally, the complete output of the problem. It's also helpful to include the output of sudo dpkg -C and sudo apt-get check, and the output of apt-cache policy package1 package2... where "package1 package2 ..." includes all the packages with problems.

share|improve this answer
    
as a diagnostic message it IS helpful if you read the entire error (Errors were encountered while processing: mongodb-10gen) that's why it is listed as E and not Error –  mchid Mar 22 at 17:39
    
@mchid but what caused the error? It doesn't give you the sightless clue. –  Braiam Mar 22 at 17:42
    
@mchid yes, how can I figure out that if I just read Errors were encountered while processing: mongodb-10gen? As it is, to solve the problem, that line is worthless. –  Braiam Mar 22 at 18:03
    
My bad I thought you were just looking for how to fix the problem ("is it possible to solve it") I guess I took that out of context. –  mchid Mar 22 at 18:09
    
BTW, run sudo touch /etc/init.d/mongodb and then run sudo apt-get purge mongodb-10gen to fix the problem. I tested this and as long as the file exists (/etc/init.d/mongodb) dpkg will proceed even if the file is empty which is what touch does (creates an empty file). –  mchid Mar 29 at 17:45

protected by Community Jan 27 at 7:57

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.