1

I've tried to remove avg2013 however when I try I get a funky error message.

The command I'm running:

sudo apt-get remove --purge avg2013flx

The error I get:

Removing avg2013flx (2013.3118) ...
Failed to stop avgd.service: Unit avgd.service not loaded.
invoke-rc.d: initscript avgd, action "stop" failed.
dpkg: error processing package avg2013flx (--purge):
 subprocess installed pre-removal script returned error exit status 5
Errors were encountered while processing:
 avg2013flx
E: Sub-process /usr/bin/dpkg returned an error code (1)

I've looked and the service is not running, but does exist.

3
  • You using Ubuntu 14.10 or 15.04? I can see a few other people on recent versions of Ubuntu with similar issues, suggests it's probably something to do with systemd (and AVG not being ready for it).
    – Oli
    Jun 2, 2015 at 15:25
  • 15.04. I've seen a few posts with similar problems.
    – Kyle
    Jun 2, 2015 at 21:06
  • This link worked for me: askubuntu.com/questions/631370/problem-removing-avg Oct 15, 2015 at 3:51

2 Answers 2

4

Same problem here, and I have a solution:

Open a terminal and open the file avg2013flx.prerm

sudo nano /var/lib/dpkg/info/avg2013flx.prerm

Search the lines with

if which invoke-rc.d >/dev/null 2>&1; then
    invoke-rc.d avgd stop
else
    /etc/init.d/avgd stop
fi

and replace ALL occurences with

#       if which invoke-rc.d >/dev/null 2>&1; then
#           invoke-rc.d avgd stop
#       else
#           /etc/init.d/avgd stop
#       fi

Than run again

sudo apt-get remove --purge avg2013flx

Explanation:

Commenting those lines out stopped the process from attempting to stop the service. And the service wasn't running anyways so it was able to remove the package.

4
  • Not sure what the rest of the file is like, but could you do all this with a single sed, like: sudo sed -i "/[[:<:]]init.d[[:>:]]/s/^/#/g" /var/lib/dpkg/info/avg2013flx.prerm ?
    – Oli
    Jun 2, 2015 at 15:49
  • That did it. Thanks, I've been fighting this and I wasn't able to find anything to fix it. I'm fairly new to Ubuntu and Linux and this was driving me crazy. So a question, why did commenting out those lines work. As far as I can tell, commenting those lines out stopped the process from attempting to stop the service. And the service wasn't running anyways so it was able to remove the package? Am I understanding that correctly?
    – Kyle
    Jun 2, 2015 at 21:04
  • @Kyle That's correct :)
    – A.B.
    Jun 3, 2015 at 3:48
  • @A.B. Thanks for your help, I really appreciate it.
    – Kyle
    Jun 4, 2015 at 5:07
1

From what I can see, people on later versions of Ubuntu (14.10, 15.04) are running into this issue. This is likely due to Ubuntu's move to the systemd init engine (what starts and stops system services).

The error you're seeing is the package's pre-removal script trying to interact with the init system and failing spectacularly.

We could assume that that's all the script is going to do. You could ignore its failure and use the dpkg --force-all flag to just carry on.

sudo dpkg -P --force-all avg2013flx

It's slightly risky if the script does more than that. We could have a look and just edit (and even fix) the pre-removal script:

sudoedit /var/lib/dpkg/info/avg2013flx.prerm

... But you need to understand what the problem is to fix it. It's undoubtedly something around a line like service stop avg. I don't have it installed (or have a want to install it just for this) so you'll have to fish around (or edit your question to include it and I'll have a look).


This has come up before on Ubuntu Forums with a fairly trivial fix:

sudo ln -s /bin/true /etc/init.d/avgd
sudo apt-get remove --purge avg2013flx

This just makes sure a fake copy of the init script exists for the removal script, allowing it to complete. Given the other answers suggest just removing the script, my original --force-all suggestion should be just as safe.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .