Nov 28, 2009

Force Uninstall a package in Debian/Ubuntu

I just did an upgrade from Jaunty to Karmic and for some reason was having a problem with xulrunner-1.9 (why was this even installed on my server in the first place?). Anyway, I couldn't uninstall it using aptitude or apt-get.. and google didn't really help me out. Fortunately I remembered a post I did on my old blog related to lighttpd and that technique helped again here.


First, here's the error I was getting when trying to remove xulrunner-1.9:

The following packages will be REMOVED:
xulrunner-1.9
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 26.9MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 45200 files and directories currently installed.)
Removing xulrunner-1.9 ...
update-alternatives: error: no alternatives for xulrunner.
update-alternatives: error: no alternatives for xulrunner.
dpkg: error processing xulrunner-1.9 (--remove):
subprocess installed pre-removal script returned error exit status 2
/usr/lib/xulrunner-1.9.0.15/xulrunner-bin: error while loading shared libraries: libplds4.so: cannot open shared object file: No such file or directory
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
xulrunner-1.9
E: Sub-process /usr/bin/dpkg returned an error code (1)


Ugly! The solution is to head over to /var/lib/dpkg/info and find the package in question. There should be a file with .prerm at the end of it. In the case of xulrunner-1.9 the file is called xulrunner-1.9.prerm. Edit the file and change it's contents so it just says:

#!/bin/sh
set -e


After that the standard command will work:

sudo apt-get remove xulrunner-1.9

10 comments:

  1. Maybe this is the root of my problems with firefox. I can't open a new window anymore, nor do some addons work properly. I've been using Chrome, liking it more and more, but I will see if this helps..

    ReplyDelete
  2. No change. I installed firefox 3.5 on Jaunty, then it has been trouble since upgrading to Karmic. I have xulrunner-1.9.1 and xulrunner-1.9.1-gnome-support installed. I can do without a few trinket addons, but it hurts a little that Ctrl-N is broken.

    ReplyDelete
  3. xulrunner is related to firefox somehow? Do you know how to fix a broken Ctrl-N in firefox?

    ReplyDelete
  4. Good explanation guys :D
    I have been fix my flashplugin-installer :D

    ReplyDelete
  5. Thanks alot... Its working....!!!

    ReplyDelete
  6. The trick for force uninstall works for me.Thank you!

    ReplyDelete
  7. Thanks, this has helped me resolve lots of broken packages in my system not only xulrunner

    ReplyDelete
  8. Thanks man! That just saved my live :) Debians apt is awesome, but not when a package breaks. In my case it was drweb-daemon.

    Cheers,
    Kim

    ReplyDelete
  9. Lifesaving post, this enabled me to uninstall "scuttle" from a crunchbang system.

    ReplyDelete