Tag Archives: /usr/bin/dpkg returned an error code (1)

Ubuntu/Debian apt-get: subprocess pre-installation script returned error exit status 1

As the title says this post is about an error showing up when trying to install packages using apt-get or aptitude and something goes wrong: subprocess pre-installation script returned error exit status 1 .

The issue in this case was created by aspell and dictionaries-common packages when trying to install aspell.
The biggest issue is that dpkg will fail with an error code of 1 even when trying to uninstall/remove/purge the package and it will not matter how hard you try:

Let’s get on the case, we will end up in a loop:

apt-get install aspell-en //will end with:

The following packages have unmet dependencies:
aspell: Depends: dictionaries-common (> 0.40) but it is not going to be installed
aspell-en: Depends: dictionaries-common (>= 0.49.2) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Next stage trying to install the unmet dependencies:

apt-get install dictionaries-common //and this will end with :

Unpacking dictionaries-common (from .../dictionaries-common_0.62.5ubuntu2_all.deb) ...
No alternatives for ispell-dictionary.hash.
dpkg: error processing /var/cache/apt/archives/dictionaries-common_0.62.5ubuntu2_all.deb (--unpack):
subprocess pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/dictionaries-common_0.62.5ubuntu2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

So something is wrong, let’s try and remove aspell-en package:

apt-get remove aspell-en //which will return again:

You might want to run `apt-get -f install' to correct these:
The following packages have unmet dependencies:
aspell: Depends: dictionaries-common (> 0.40) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Hmm, what the hack???
Try and do what it says:

apt-get -f install //guess what will be the return at the end:

Unpacking dictionaries-common (from .../dictionaries-common_0.62.5ubuntu2_all.deb) ...
No alternatives for ispell-dictionary.hash.
dpkg: error processing /var/cache/apt/archives/dictionaries-common_0.62.5ubuntu2_all.deb (--unpack):
subprocess pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/dictionaries-common_0.62.5ubuntu2_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

So now we are in a loop and nothing helps really, you can try and run for example dpkg --purge --force-depends dictionaries-common or any other derivative commands including purge or remove but may be that not one of them will help here.

What to do?

Well an option will be to check the package in question inn the dpkg libraries directory /var/lib/dpkg/info/ .
Checking that directory for aspell-en(which actually is the cause in this case) you will see a few files:

aspell-en.postinst
aspell-en.postrm
aspell-en.list
aspell-en.prerm

One of this files(which are actually small scripts) is creating that error when installing or uninstalling so we are unable to remove aspell-en anymore.

A fix around this will be to edit the /var/lib/dpkg/info/aspell-en.postrm file(in our case we want to remove the file) and add exit 0 after the set -e so that in the end the line will look like:

set -e exit 0

Save and try again to remove the package:

dpkg --purge --force-depends aspell-en //you should be able to remove the package just fine

Now, what caused all this mess? Well in this specific case it was the dictionaries-common package which i suspect it was borked.
After grabbing another package(dictionaries-common package) from the internet(debian repositories) and installing it and tried to install aspell-en again everything run fine and got it installed with no issue or error.

The problem here was based on aspell-en and dictionaries-common packages but the same case/problem seems to be on going for other packages that will return same error code.

Share/Bookmark