Archive for April 2019

Broken `apt-get update` Due To AppStream Error

Over this past weekend, I was trying to update my office desktop to the latest Ubuntu version, and hit a snag. It was giving an error on AppStream, so I tried to remove it using apt-get remove, but that, too, gave me errors, as you can see here:

Fetched 3,222 kB in 1s (1,836 kB/s)                           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
# apt-get remove libappstream3
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libappstream3

A quick realization made me change libappstream3 to libappstream4, but that gave me a bit of a startling result:

# apt-get purge libappstream4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  gnome-software-common lib32gcc1 libcuda1-384 libebur128-1 libegl1-mesa:i386 libgtkspell3-3-0 libidn11:i386 libpython3.6-minimal libsnapd-glib1 libstemmer0d libva-wayland1 nvidia-headless-390
  nvidia-opencl-icd-384 python3.6-minimal rename snapd-login-service xserver-xorg-legacy
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  appstream* gnome-software* gnome-software-plugin-snap* libappstream4* ubuntu-software*
0 upgraded, 0 newly installed, 5 to remove and 1932 not upgraded.
After this operation, 2,199 kB disk space will be freed.
Do you want to continue? [Y/n]

Whoa, there, champ. Hold your horses. I don’t feel like having my finally-working four-head Gnome display configuration getting hosed and having to do it all over again. So instead of removing, I tried reinstalling over top of the existing install:

# apt-get install --reinstall libappstream4
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  lib32gcc1 libcuda1-384 libebur128-1 libegl1-mesa:i386 libidn11:i386 libpython3.6-minimal libva-wayland1 nvidia-headless-390 nvidia-opencl-icd-384 python3.6-minimal rename xserver-xorg-legacy
Use 'apt autoremove' to remove them.
The following packages will be upgraded:
  libappstream4
1 upgraded, 0 newly installed, 0 to remove and 1936 not upgraded.
Need to get 0 B/97.2 kB of archives.
After this operation, 33.8 kB of additional disk space will be used.
(Reading database ... 349307 files and directories currently installed.)
Preparing to unpack .../libappstream4_0.12.0-3ubuntu1_amd64.deb ...
Unpacking libappstream4:amd64 (0.12.0-3ubuntu1) over (0.10.6-2) ...
Setting up libappstream4:amd64 (0.12.0-3ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

Boom. Good to go. Now apt properly updates, and I can continue merrily on my way.