Problem with appstreamcli when running apt update

After Googling I found some people saying that removing the package appstream will fix the problem.

This solution will work but in many cases this approach will remove packages that you may not want to remove.

An alternate solution is to comment the three last lines in /etc/apt/apt.conf.d/50appstream file like this:

...
#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 | true; fi";
#};

and then save the file and run apt-get update again.

After running a system upgrade there is a chance that the package appstream will have a upgrade that can fix this error and a message like this may appear:

Configuration file '/etc/apt/apt.conf.d/50appstream'
  ==> Modified (by yourself or by a script) since the installation.
  ==> The package distributor has released an updated version.
    What do you want to do? Your options are:
     Y or I: install the version of the maintainer package
     N or O: keep the currently installed version
       D: Show differences between versions
       Z: start a shell to examine the situation

You should say Y to upgrade the file you have modified.

I'm posting this to help others that may search for this error.


apt-get clean

Emptying the apt cache seems to have solved it for me too. Then I could run

apt-get update

without any problem or warning.

Edit: Maybe I was too fast. After cleaning the cache the error was gone, but later it occurred again.