Debian / Ubuntu Package Troubleshooting: subprocess post-removal script returned error exit status xx

by Vivek Gite · 10 comments

Here is a quick way to fix half installed packages under Debian / Ubuntu Linux.

If you see an error while removing or installing debian / ubuntu package that read as follows:

(Reading database ... 147148 files and directories currently installed.)
Preparing to replace octopussy 0.9.6.2 (using octopussy_0.9.6.2_all.deb) ...
Unpacking replacement octopussy ...
dpkg: warning - old post-removal script returned error exit status 10
dpkg - trying script from the new package instead ...
dpkg: error processing octopussy_0.9.6.2_all.deb (--install):
subprocess new post-removal script returned error exit status 10
dpkg: error while cleaning up:
subprocess post-removal script returned error exit status 10
Errors were encountered while processing:
octopussy_0.9.6.2_all.deb

In above octopussy package is not getting removed because of script error. Mostly these are shell script written using /bin/sh. These scripts called with -e option which means if not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an && or || operator. In short shell scripts will abort with an error if something fails. To fix this problem visit /var/lib/dpkg/info directory
# cd /var/lib/dpkg/info
Now find out files in following format:
packagename.*
octopussy.*
$ ls octopussy.*
Now open each file and find out line that read as follows:
#/bin/sh -e
Replace with
#/bin/sh
Save and close all the files. Now run apt-get / dpkg command again to remove package:
# apt-get --purge remove octopussy
OR
# dpkg -r octopussy

Featured Articles:

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 10 comments… read them below or add one }

1 Euler d. Graca 06.06.08 at 10:49 am

Thanks a lot! It saved my day!

2 kuro 06.24.08 at 2:54 pm

Nice tip man, it really useful

3 Thomas 09.11.08 at 2:43 am

Worked just as written! Thank you!

4 Feudjay 11.25.08 at 7:12 am

Hey,

very nice tip man I thought that I will never remove my package !!!

Just one thing I had in my files in /var/lib/dpkg/info/ one of my packageÅ› file with a #!/bin/sh -e but others files were with a “good” #!/bin/sh and 2 lines after a vicious line :
set -e
You need to comment it !!!

Thanks thanks thanks

jeff

5 Joe 03.21.09 at 8:22 am

Sweet.. had this problem with vagalume… really appreciate it…

6 Michael 06.02.09 at 12:53 pm

Thanks!

7 Ruud 06.05.09 at 7:17 pm

I had a similar problem however I did not have “#/bin/sh -e” in my package scripts.
Instead I had “set -e” which I simply uncommented.

8 rMarmolejoR 07.19.09 at 3:36 pm

Thanks man, I really appreciate your post, I didn’t had any problem of the above mentioned, mine was a corrupted postrm file, that I was able to figure out following your post.

Thanks again

9 Pavel 07.20.09 at 10:33 pm

Thanks!!!! I found that I was looking for.

10 sugster 09.22.09 at 7:22 pm

Very useful. Ekiga crashed part way through so this helped me clean it up. Thanks!

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Previous post:

Next post: