subprocess pre-removal script returned error exit status 2? error
Recently, I encountered a package management related error in Ubuntu Jaunty Jackalope 32bit.
The package was sharutils and the error was: “E: sharutils: subprocess pre-removal script returned error exit status 2? and details showed:
“dpkg (subprocess): unable to execute pre-removal script: Exec format error
dpkg: error processing sharutils (–remove):
subprocess pre-removal script returned error exit status 2
dpkg (subprocess): unable to execute post-installation script: Exec format error
dpkg: error while cleaning up:
subprocess post-installation script returned error exit status 2
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)”
I managed to fix it. Read on for how I did it.
Precaution: The process can break your system if not followed as mentioned (you may get into problems even if you follow the process). Please proceed at your own risk.
First, please try the following in terminal:
sudo aptitude update sudo aptitude -f install
If it does not work, then you may want to try:
sudo dpkg --force all --remove
If both of them still produce similar errors, then continue. If the above commands fix your problem, you should not continue.
1. Close Synaptic or any package manager. Wait for or cancel any updates or install\uninstall.
2. Make Backups of current /var/lib/dpkg/status file. Just copy and paste to your home directory or Desktop.
3. Alt+F2 and launch type in gksu gedit /var/lib/dpkg/status and run it. Gedit will be launched with a text file open.
4. Now, search for the exact name of the package with problems and find it.
5. In my case, it I found the entry for the package sharutils:
Package: sharutils Status: deinstall ok half-configured Priority: standard Section: utils Installed-Size: 968 Maintainer: Ubuntu Core Developers <firstname.lastname@example.org> Architecture: i386 Version: 1:4.6.3-1build1 Depends: libc6 (>= 2.6-1) Suggests: mailx Conflicts: shar, uuencode Description: shar, unshar, uuencode, uudecode `shar' makes so-called shell archives out of many files, preparing them for transmission by electronic mail services. `unshar' helps unpacking shell archives after reception. Other related utility programs help with other tasks. . `uuencode' prepares a file for transmission over an electronic channel which ignores or otherwise mangles the eight bit (high order bit) of bytes. `uudecode' does the converse transformation. Original-Maintainer: Santiago Vila <email@example.com>
6. Select and delete that information and that much information only, i.e. you will remove “Package: culprit-package-name” to “Description: culprit package description”. Remmber, “culprit package description” may be multiline and you will need to remove all the lines till a blank line. Don’t forget to leave a line blank between the package description above and the one below. Be careful delete only the culprit package information. As i have mentioned in the highlighted box.
7. Launch Synaptic (or any package manager) and then search for package. You will see the package as not installed. Mark it for installation and install it. If you start to see the same error, restart the same process from Step 1 but the next time, stop at step 6.
8. Now, you should be able to remove it if you no longer want the package. If you can’t, restart the same process from Step 1 but the next time, stop at step 6.
This resolved my problem, hope will resolve yours too…
NOTE: All credit goes to http://www.khattam.info/2009/08/04/solved-subprocess-pre-removal-script-returned-error-exit-status-2-error/