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
🐧 22 comments so far... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Thanks It saved my life
Thanks, fellas, you saved my day 🙂
Hi, I have the same problem with Kubuntu, every time am trying to update it from the “Update System” I get that error and it will not allow me to do it, please any help in that?
thx (y), useful
Thanks a lot.
I remember I read this somewhere long time ago. I forgot it when I needed.
Thanks again.
~faizlo
As with #4 Feudjay & #7 Ruud I did not have “#/bin/sh -e†in any of my package scripts.
I too had “set -eâ€, but it turns out simply deleting the “-e” at the end of “set -e” made it all worked like a charm.
mary@mary-laptop:~$
mary@mary-laptop:~$
mary@mary-laptop:~$
mary@mary-laptop:~$
mary@mary-laptop:~$
mary@mary-laptop:~$
I mean, I don’t know *how many* of these files have to be edited, sorry. In my case there were at least about 6 of them (according with the post, I didn’t bother to check to see if each one of them had the -e option), so doing it all with a command for backup and another to editing it all makes everything a bit faster.
Thanks for the tip!
I don’t know how much of these files have to be edited, so I used sed in the following manner:
for i in `ls octopuss*` ; do sed -ie ‘s|^set -e|#set -e|g’ $i ; done
(but depending on the package you might need to use ‘s|#/bin/sh -e|#/bin/sh|g’ — as stated in the first post)
You may want to have a backup of these files in some folder to restore them if something goes wrong, before doing that.
For those of you that (even after following these awesome directions) can’t get your package uninstalled, here is the sure fire method:
WARNING: BACK UP /var/lib/dpkg/* before doing this!
Edit /var/lib/dpkg/status
Edit /var/lib/dpkg/status-old
Remove the section in these files for your package, then save the file.
BE CAREFUL!
apt-get update && apt-get upgrade
your package should be gone!
ahhhh.
that did it.
the posted method didn’t work for me, it just gave more errors about yet more missing files after editing the -e lines out.
the manual removal from the two files you specified worked great!
thank you.
I still can’t get the failed install of Bittorrent and Banshee to remove.
E: banshee: subprocess installed post-removal script returned error exit status 2
E: bittorrent-gui: subprocess installed post-removal script returned error exit status 2
Very useful. Ekiga crashed part way through so this helped me clean it up. Thanks!
Thanks!!!! I found that I was looking for.
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
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.
Thanks!
Sweet.. had this problem with vagalume… really appreciate it…
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
Worked just as written! Thank you!
Nice tip man, it really useful
Thanks a lot! It saved my day!