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: =========
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

  • 1
    Related bug: bugs.debian.org/cgi-bin/bugreport.cgi?bug=822317
    – Elder Geek
    Commented Oct 29, 2017 at 23:34
  • Maybe this problem has something to do with Python (version? home folder? I don't know). I explain: I had a similar problem on Ubuntu 20, but the answers here didn't work for me. However, the problem disappeared when I realized that I had changed the symbolic link /usr/bin/python3 to /usr/bin/ph3 (yeah, laziness...) a couple of minutes before the error started to show up. When I put it back to \usr\bin\python3 both the sudo apt update and sudo apt upgrade worked well. Maybe some of the programs that are been updated/upgraded need Python. Please, check this out. I hope it helps. Commented May 9, 2020 at 23:32
  • 1
    Currently having exactly the same error within docker image ubuntu:latest (sha256:18b083992355354958fd861c9f89b393f34d27442c07fa7492a5dbbd516b1c9a). Interesting how this error keeps coming back over the years!
    – Frans
    Commented Apr 22, 2022 at 15:34

8 Answers 8


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

sudo apt-get purge libappstream3
  • 8
    What about the side effects? What caused this issue?
    – EdParadox
    Commented Aug 9, 2017 at 18:20
  • 4
    @EdParadox This happened to me yesterday when updating the software in Ubuntu 16.04 immediately after installing it in VirtualBox with the command sudo apt upgrade. This answer worked for me. I was getting many other Apport error notifications at the same time. After updating Oracle VirtualBox and Oracle VirtualBox Extension Pack to the latest version these errors disappeared. I checked in /var/crash/ and verified that all of these errors were related to appstream which has libappstream3 as a dependency.
    – karel
    Commented Aug 10, 2017 at 7:38
  • 5
    @EdParadox The cause? In my case, the error just happened with no apparent reason, when running sudo apt-get update command in Terminal. The side effect? Nothing apparent besides these packages appstream gnome-software libappstream3 being removed.
    – user37165
    Commented Aug 11, 2017 at 7:50
  • 5
    @Lion Just did a completely fresh install of XUbuntu 16.04 here on real hardware, I got it right away; I've never had this happen before on any other Linux distro; I'd take a guess and say that there might be something wrong with the installer.
    – jrh
    Commented Sep 30, 2017 at 3:35
  • 5
    This really saved my a**. Thanks. It's strange that one dumb package would completely fubar an entire fresh install.
    – Cerin
    Commented Mar 24, 2018 at 2:40
sudo apt install --reinstall libappstream3

can fix it.

  • 1
    this fixed this error for me.
    – Brock Vond
    Commented Jan 11, 2018 at 0:10
  • 5
    I ran apt install --reinstall libappstream*
    – jtlindsey
    Commented Apr 15, 2018 at 18:35
  • 2
    Way better solution than the accepted answer, it prevents extra packages from being removed as well (at least on KDE).
    – kursus
    Commented Sep 3, 2018 at 17:55
  • I get an error: The following packages have unmet dependencies: code : Depends: libnss3 (>= 2:3.26) but 2:3.21-1ubuntu4 is to be installed
    – FAQ
    Commented Sep 21, 2018 at 16:34
  • If this works it would be better, agreed. As I recall.. I tried it but got some dependency error. Commented Oct 4, 2018 at 9:00

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.

  • 1
    For me that did the trick - removing fwupd.xml and re-installing libappstream4. Thanks!
    – valiano
    Commented Jul 22, 2018 at 5:22
  • 1
    B4 your procedure, I backed up fwupd.xml and 50appstream. After your procedure, the errors disappeared after sudo apt update ( tested for a few reboots). I reinserted 50appstream to original location, ran sudo appstreamcli refresh --force followed by sudo apt update; no error msg. After reinserting fwupd.xml and do refresh --force and update commands, this error appeared AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml. So fwupd.xml caused error. The symbol & in line 265 is the likely cause?
    – Sun Bear
    Commented Jul 23, 2018 at 9:35
  • 1
    bugs.launchpad.net/ubuntu/+source/appstream/+bug/1644498 A fix was released in 2017/01 but in 2018/07 this same issue reappears. Think the previous bug fix is no longer working for current error? Seems to be an up trend of this error... Hope a new solution can be found.
    – Sun Bear
    Commented Jul 23, 2018 at 9:40
  • 2
    I concluded the files fwupd.xml and 50appstream should not be removed. They have a purpose. I have posted my solution here. After fixing the typo in fwupd.xml, everything works again.
    – Sun Bear
    Commented Jul 23, 2018 at 15:41
  • 1
    @Sun Bear I had this exact same problem and your solution worked for me. Thanks
    – Scooby-2
    Commented Aug 5, 2018 at 18:45

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.


In my case, purging, or re-installing didn't help.

The removal of the apt.conf.d entry did however solve the issue for me.

Friday 25 August  22:17:45 AEST 2017
LSB Version:    core-9.20160110ubuntu0.2-amd64:core-9.20160110ubuntu0.2-noarch:printing-9.20160110ubuntu0.2-amd64:printing-9.20160110ubuntu0.2-noarch:security-9.20160110ubuntu0.2-amd64:security-9.20160110ubuntu0.2-noarch
    Distributor ID: Ubuntu
    Description:    Ubuntu 16.04.3 LTS
    Release:    16.04
    Codename:   xenial

I ran the following commands to get rid of the error:

sudo apt-get purge libappstream2
sudo rm /etc/apt/apt.conf.d/50appstream

For having this:

$ sudo apt-get update
[sudo] password for XXX:           

AppStream system cache was updated, but problems were found: Metadata files have errors: /var/cache/app-info/xmls/fwupd.xml
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-cache > /dev/null; fi'
E: Sub-process returned an error code

$ sudo appstreamcli --version
AppStream CLI tool version: 0.10.6

$ sudo appstreamcli refresh-cache --force --verbose
** (appstreamcli:15334): DEBUG: Added /usr/share/app-info/xmls to metadata search path.
** (appstreamcli:15334): DEBUG: Added /var/lib/app-info/yaml to metadata search path.
** (appstreamcli:15334): DEBUG: Added /var/cache/app-info/xmls to metadata search path.
** (appstreamcli:15334): DEBUG: Refreshing AppStream cache
** (appstreamcli:15334): DEBUG: Searching for data in: /usr/share/app-info/xmls
** (appstreamcli:15334): DEBUG: Searching for data in: /var/cache/app-info/xmls
** (appstreamcli:15334): DEBUG: Searching for data in: /var/lib/app-info/yaml
** (appstreamcli:15334): DEBUG: Reading: /usr/share/app-info/xmls/org.freedesktop.fwupd.xml
** (appstreamcli:15334): DEBUG: Reading: /var/cache/app-info/xmls/fwupd.xml
** (appstreamcli:15334): DEBUG: WARNING: Could not parse XML data: Entity: line 265: parser error : EntityRef: expecting ';'
        <checksum filename="Firmware_SF30&SN30_Pro_V1.26.dat" target="content" t

The fix is:

$ sudo -i

# cd /var/cache/app-info/xmls/

# ls -l
total 236
drwxr-xr-x 2 root root   4096 jul 27 09:56 ./
drwxr-xr-x 5 root root   4096 aug 31  2017 ../
-rw-r--r-- 1 root root 233177 jun 29 16:02 fwupd.xml

# sed < fwupd.xml  -rne 's/Firmware_SF30\&SN30_Pro_V1.26.dat/Firmware_SF30\&SN30_Pro_V1.26.dat/gp'
        <checksum filename="Firmware_SF30&SN30_Pro_V1.26.dat" target="content" type="sha1">3ef2bdee8aca2a45b9f53b4d4cce9722523f57f8</checksum>

# sed fwupd.xml -i_BACKUP -re 's/Firmware_SF30\&SN30_Pro_V1.26.dat/Firmware_SF30\&SN30_Pro_V1.26.dat/gp'

# ls -l
total 464
drwxr-xr-x 2 root root   4096 jul 27 09:57 ./
drwxr-xr-x 5 root root   4096 aug 31  2017 ../
-rw-r--r-- 1 root root 233328 jul 27 09:57 fwupd.xml
-rw-r--r-- 1 root root 233177 jun 29 16:02 fwupd.xml_BACKUP

# rm fwupd.xml_BACKUP

# apt-get update
Hit:1 http://se.archive.ubuntu.com/ubuntu xenial InRelease
Fetched 491 kB in 0s (715 kB/s)                    
Reading package lists... Done

# exit




A working solution in 18.04.1 is to install appstream and libappstream4 manually from the Cosmic repos; pick your architecture and a mirror, download, install with dpkg -i, then try appstreamcli refresh --force.


Ubuntu 18.04 and later

In Ubuntu 18.04 and later open the terminal and type:

sudo apt install --reinstall libappstream4

You can also test the above command before running it without making any changes to your system (so sudo is not required).

apt install --reinstall --simulate libappstream4

You must log in to answer this question.

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