Yast SW Managemet 'cannot read list of installed packages'

How do I get out of this one? Yast SW management cannot read the list of installed packages.

It happened after I ‘installed’ the ‘Plan’ application (Calligra Plan?) using the Gnome ‘Software’ package application. The application did not start after it was installed, so I thought there might be some missing dependencies and added the repository ‘KDE extra’. From that moment everything went pear-shaped.

I am using OpenSuse 13.2 (64-bit) / Gnome 3.14.2

Immediately after starting the SW manager from the Yast GUI the log contains

sudo tail /var/log/YaST2/y2log
2015-10-09 22:41:03 <1> linux-lueh(11941) [liby2] genericfrontend.cc(main):783 Exiting with client return value '`next'
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [zypp] PathInfo.cc(recursive_rmdir):435 recursive_rmdir /var/tmp/zypp.DpBIyN 
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [zypp++] TmpPath.cc(~Impl):78 TmpPath cleaned up /var/tmp/zypp.DpBIyN{d 0700 0/0}
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [zypp] ZYppFactory.cc(_openLockFile):166 Open lockfile /var/run/zypp.pid
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [zypp] ZYppFactory.cc(~ZYppGlobalLock):115 Cleanned lock file. (11941)
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [zypp] ZYppFactory.cc(_closeLockFile):184 Close lockfile /var/run/zypp.pid
2015-10-09 22:41:03 &lt;2&gt; linux-lueh(11941) [qt-ui] YQUI.cc(qMessageHandler):725 &lt;libqt-warning&gt; QObject::~QObject: Timers cannot be stopped from another thread
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [Pkg] PkgFunctions.cc(~PkgFunctions):158 Releasing the zypp pointer...
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [Pkg] PkgFunctions.cc(~PkgFunctions):160 Zypp pointer released
2015-10-09 22:41:03 &lt;1&gt; linux-lueh(11941) [Y2Ruby] binary/YRuby.cc(~YRuby):107 Shutting down ruby interpreter.

I have now the following set of repositories

 zypper lr -d
# | Alias                              | Name                               | Enabled | GPG Check | Refresh | Priority | Type   | URI                                                                  | Service
--+------------------------------------+------------------------------------+---------+-----------+---------+----------+--------+----------------------------------------------------------------------+--------
1 | download.opensuse.org-13.2-non-oss | Update Repository (Non-Oss)        | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/13.2-non-oss/                    |        
2 | download.opensuse.org-Apps         | openSUSE BuildService - GNOME:Apps | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/repositories/GNOME:/Apps/openSUSE_13.2/ |        
3 | download.opensuse.org-non-oss      | Main Repository (NON-OSS)          | Yes     | (r ) Yes  | Yes     |   99     | yast2  | http://download.opensuse.org/distribution/13.2/repo/non-oss/         |        
4 | download.opensuse.org-oss          | Main Repository (OSS)              | Yes     | (r ) Yes  | Yes     |   99     | yast2  | http://download.opensuse.org/distribution/13.2/repo/oss/             |        
5 | download.opensuse.org-update       | Main Update Repository             | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://download.opensuse.org/update/13.2/                            |        
6 | ftp.gwdg.de-suse                   | Packman Repository                 | Yes     | (r ) Yes  | Yes     |   99     | rpm-md | http://ftp.gwdg.de/pub/linux/packman/suse/openSUSE_13.2/          

Try to clean all zypp caches, and rebuild the RPM database:

sudo zypper clean -a
sudo rpmdb --rebuilddb

‘sudo zypper clean -a’ fails with the following message


error: rpmdb: fop_read_meta: /var/lib/rpm/Packages: unexpected file type or format
error: cannot open Packages index using db4 - Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm
Target initialization failed:
Rpm Exception
Cannot clean installed packages cache because of an error.
Some of the repositories have not been cleaned up because of an error.


I have not tried the other command. Should I anyway?

…and the reason is that the /var/lib/rpm/Packages file is empty, i.e 0 bytes long.

Well, that’s bad, but it explains your problems.

You can try “rpmdb --rebuilddb”, but I don’t think it can repair that, as all data from the main database is missing.
I think the only way to repair that (except for removing /var/lib/rpm/ and reinstalling all packages) is to restore a backup from /var/adm/backup/rpmdb/. If you’re lucky that’s quite recent…

This is not looking good

linux-lueh:/var/adm/backup/rpmdb # ls -ls
total 188892
47180 -rw-r--r-- 1 root root 48311572 Oct  4 19:30 Packages-20151004.gz
47236 -rw-r--r-- 1 root root 48368567 Oct  6 19:30 Packages-20151006.gz
47236 -rw-r--r-- 1 root root 48369019 Oct  7 19:30 Packages-20151007.gz
47232 -rw-r--r-- 1 root root 48363654 Oct  8 19:30 Packages-20151008.gz
    4 -rw-r--r-- 1 root root       20 Oct  9 19:30 Packages-20151009.gz
    4 -rw-r--r-- 1 root root       36 Oct  9 19:30 rpmdb_recent_md5

How do I restore what (probably the Oct 8 package) to where and how?

It is, I’d say…

How do I restore what (probably the Oct 8 package) to where and how?

Extract the file Packages-20151008.gz, and copy it over /var/lib/rpm/Packages/, e.g.:

gunzip /var/adm/backup/rpmdb/Packages-20151008.gz
mv /var/adm/backup/rpmdb/Packages-20151008 /var/lib/rpm/Packages

OK. I did that and Yast works again! Many thanks for your help!

One last thing though…
Now I have three packages that want to be updated with newer versions all from the main update repository. These three updates fail with e.g.

  Subprocess failed. Error: RPM failed: error: rpmdb: fop_read_meta: /var/lib/rpm/Name: unexpected file type or format
 error: cannot open Name index using db4 - Invalid argument (22)
 warning: /var/cache/zypp/packages/download.opensuse.org-update/x86_64/dracut-037-17.24.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 3dbdc284: NOKEY
 error: rpmdb: fop_read_meta: /var/lib/rpm/Name: unexpected file type or format
 error: rpmdb: fop_read_meta: /var/lib/rpm/Name: unexpected file type or format
 error: rpmdb: fop_read_meta: /var/lib/rpm/Name: unexpected file type or format
 error: rpmdb: fop_read_meta: /var/lib/rpm/Group: unexpected file type or format
 error: cannot open Group index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Requirename: unexpected file type or format
 error: cannot open Requirename index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Providename: unexpected file type or format
 error: cannot open Providename index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Conflictname: unexpected file type or format
 error: cannot open Conflictname index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Obsoletename: unexpected file type or format
 error: cannot open Obsoletename index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Dirnames: unexpected file type or format
 error: cannot open Dirnames index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Installtid: unexpected file type or format
 error: cannot open Installtid index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Sigmd5: unexpected file type or format
 error: cannot open Sigmd5 index using db4 - Invalid argument (22)
 error: rpmdb: fop_read_meta: /var/lib/rpm/Sha1header: unexpected file type or format
 error: cannot open Sha1header index using db4 - Invalid argument (22)

By the way, the three packages are dracut (above), timezone and timezone-java

Ok, so some of the other files in /var/lib/rpm/ seem to be corrupted too.
You can recreate those with “rpmdb --rebuilddb” though.

…and that worked, too…many thanks indeed.