How to debug dpkg configure error in subprocess post-installation?

In short: I am trying to install spamassassin but dpkg returns only with:

dpkg: error processing spamassassin (--configure):
subprocess installed post-installation script returned error exit status 1

I have tried to find more information about what is going wrong but I cannot find anywhere any useful logging.

In /var/crash a spamassassin crashreport is generated but this gives only old dpkg errors and:

 Start-Date: 2014-02-17  19:18:13
 Commandline: apt-get install spamassassin
 spamassassin: Configure
 amavisd-new-postfix: Configure

Followed by dmesg logging from startup.
Amavis gives an error because dependency spamassassin is not configured.

I checked the log files:

apt history.log
apt term.log

but no additional information.

I tried dpkg -D with all possible octals but I find nothing useful about what could go wrong.

Lots of questions and possible solutions have been written about dpkg errors and many I have tried, but with no additional information I do not have the feeling I am getting anywhere.

Surely there must be somewhere a possibility to read what is going wrong or to crank up some logging so it will be logged?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Ok, I have found the solution for this problem. Thought I was unable to crank up the logging to get more data, the data already presented had the clue to the problem.

dpkg: error processing spamassassin (--configure):
subprocess installed post-installation script returned error exit status 1

says dpkg encountered an error processing spamassassin while running configure. Next line tels us the post-installation script did not finish correct.

In the /var/lib/dpkg/info dir we can locate the script files of dpkg, the file: spamassassin.postinst gives us the script file which generated the error.

Within this file we know we have to look at the code runned by configure:

if [ “$1” = “configure” ]; then

and after some debugging I found out the line:

su debian-spamd -c “sa-update –gpghomedir /var/lib/spamassassin/sa-update-keys \
–import /usr/share/spamassassin/GPG.KEY”

returned exit code 1 (run command @commandline and use echo $? next to get the exit code)

The problem was that the user debian-spamd already existed on my system but its login shell was /bin/false. Su-ing with /bin/false returns without any message but exitcode 1.

Adding -s /bin/sh to the command solved the problem though in the end I did alter the login shell of the user to stay in sync with future updates.

Solution 2

Generally to debug such issues, you would edit /var/lib/dpkg/info/spamassassin.postinst (or .preinst, pr .prerm or .postrm; depending on which one is failing) and change #!/bin/sh at the top line to #!/bin/sh -x (same thing if it bash instead: just add -x)

That would provide you with line-by-line debug of shell script, so you could tell where it exits with non-zero code (causing the installation/upgrade to fail).

It would probably require at least some shell scripting skills to debug, though.

Solution 3

Here, like the previous answer, we see how to add debugging code, (e.g., "set -x") to an /var/lib/dpkg/info/* file, BUT without having it get overwritten just before execution!:

  # dpkg --unpack /var/cache/apt/archives/grub-pc_2.06-2_amd64.deb
  ... edit /var/lib/dpkg/info/grub-pc.postinst ...
  # dpkg --configure grub-pc

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply