Manually remove a broken package in Ubuntu/Debian

Recently I’ve had a problem with one of the packages (“deployment-daemon-zend-server”) that went broken after system upgrade, so that no updates or even new software could be installed. Here’s an error message I kept getting:
dpkg: error processing deployment-daemon-zend-server (--remove):
subprocess installed pre-removal script returned error exit status 127

That’s a nasty problem cause it has to be solved per hand – no automatic fixes via update manager and software center worked for me, I also tried the force removal of the package this way:
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME
And it didn’t work either. So the solution here is to find all the package files, move them to a temporary directory and then force-remove the package. Following code did the job (replace PACKAGE_NAME with the name of the broken package):
sudo mv /var/lib/dpkg/info/PACKAGE_NAME.* /tmp/
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME

36 thoughts on “Manually remove a broken package in Ubuntu/Debian

    • Hi Frank, nice to hear! Thanks for the feedback, not sure what query table you meant though 🙂
      Yuriy

  1. I love you for this!
    I was just about to get nuts with a testing package I shouldn’t have installed. The post removal script didn’t work, and had no idea how to fix that. (Didn’t have to 😀 )
    The package, for reference, is a python-uniconvertor testing build, for Ubuntu (I installed on debian, I know :$ )

  2. Learned a new command line trick and got rid of a corrupt package that was clogging up apt. All from an article you wrote 3 years ago. Made my evening, thanks!

  3. I’m in same situation with some held package stopping synaptic & apt-get from doing anything.

    How do you find out the name of the held package ?

    I would need that to use your command. So far I’ve not been able to name the trouble maker.

    Any help will save my sanity 🙂

    oldgeezer

    • hey oldgeezer! if you tried to remove it via synaptic, you’d have to see its name there.

      Otherwise you have to know something about the package – try using dpkg-query command to get its name by the thing you know about it: dpkg-query -l ‘pattern’

  4. Awesome. Thanks. This just got me out of a problem with the cqrlog package from a PPA in Ubuntu 14.04. Commenting in case this helps anyone else out who is having problems removing or upgrading cqrlog as googling didn’t give me much to go on. I’ll just mention cqrlog another 3 times for good measure – cqrlog, cqrlog.

  5. Worked great for nuking a package that only had startup scripts and refused to be removed because the service the scripts belonged to was no longer installed and so couldn’t be stopped by the pre-remove script…
    stupid.

  6. After hours of searching and countless ‘solutions’ attempted and failed, your advice worked. Thank you!

  7. Still working solution on Ubuntu 18.04, two people had problems with a printer driver package.

    Thanks so much

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.