E: Problem executing scripts APT Update::Post-Invoke-Success error during apt-get update

I cannot install any package. It seems the command apt-get update must be run but it throws some errors:

$ sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]     
Hit:2 http://ve.archive.ubuntu.com/ubuntu xenial InRelease                     
Hit:3 http://ve.archive.ubuntu.com/ubuntu xenial-updates InRelease             
Hit:4 http://ve.archive.ubuntu.com/ubuntu xenial-backports InRelease           
Fetched 102 kB in 23s (4337 B/s)                                               
*** Error in `appstreamcli': double free or corruption (fasttop): 0x000000000210f4b0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fac8d8317e5]
[...]
Aborted (core dumped)
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 
 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; 
 then appstreamcli refresh > /dev/null; fi'
E: Sub-process returned an error code

Full terminal output.txt


This worked for me (From here, https://forum.siduction.org/index.php?topic=6174.0):

sudo apt-get purge libappstream3

sudo apt install --reinstall libappstream3

can fix it.


I came from this page and was redirected here, over there I cannot answer but this is actually an answer for that page. Since I had the same issue (at least same as one of the related issues, but hey I did not relate them so sorry if it is not right solution for you ) and found it quite difficult to find the right information, but in the end succeeded, I thought why not share it here. It took me 2 days evening hours to put the pieces together but this is what I did, hope it helps some of you.

I followed this procedure to clean the mess, made a backup first, just in case.

sudo apt install appstream/xenial-backports
sudo rm /etc/apt/apt.conf.d/50appstream
sudo rm /var/cache/app-info/xmls/fwupd.xml
sudo apt install --reinstall libappstream4
sudo appstreamcli refresh --force
sudo reboot

Not sure if the reboot is necessary but after reboot I did:

sudo appstreamcli refresh --force

and had no more errors.


I had this issue after upgrading from 16.04 LTS to 18.04.1 LTS. My initial error message was:

AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml

Here is what I did to fix it:

$ sudo rm /var/cache/app-info/xmls/fwupd.xml
$ sudo appstreamcli refresh --force

That resulted in this terminal message:

AppStream cache update completed successfully.

Then, sudo apt-get update and sudo apt-get upgrade worked perfectly.