Arch Linux: package-query: error while loading shared libraries: libalpm.so.11

By | 10/26/2019

Didn’t install upgrades for a couple of weeks, today packages to be upgraded became over 100, so I run it.

Upgrades on my Arch Linux are installed with a simple alias in the.bashrc:

...
alias osupgrade="yaourt -Syua --noconfirm"
...

(seems eventually it’s time to change it to the alias osupgrade="yay -Syua --noconfirm")

The error

Usually, it works greats (under the hood yaourt anyway will use pacman for packages from the official repository) and almost two years was no issues, but today an upgrade process stopped with errors:

[simterm]

...
(20/21) Updating the desktop file MIME type cache...
(21/21) Updating the MIME type database...
package-query: error while loading shared libraries: libalpm.so.11: cannot open shared object file: No such file or directory
==> ERROR: unable to update
package-query: error while loading shared libraries: libalpm.so.11: cannot open shared object file: No such file or directory
==> ERROR: unable to update
package-query: error while loading shared libraries: libalpm.so.11: cannot open shared object file: No such file or directory
==> ERROR: unable to update
package-query: error while loading shared libraries: libalpm.so.11: cannot open shared object file: No such file or directory
==> ERROR: unable to update
package-query: error while loading shared libraries: libalpm.so.11: cannot open shared object file: No such file or directory
No database errors have been found!

[/simterm]

Check the package-query package dependencies:

[simterm]

$  ldd /usr/bin/package-query
        ...
        libalpm.so.11 => not found
        ...

[/simterm]

But files are present on the system:

[simterm]

$ ls -l /usr/lib/libalpm.so*
lrwxrwxrwx 1 root root     17 Oct 22 05:06 /usr/lib/libalpm.so -> libalpm.so.12.0.0
lrwxrwxrwx 1 root root     17 Oct 22 05:06 /usr/lib/libalpm.so.12 -> libalpm.so.12.0.0
-rwxr-xr-x 1 root root 223616 Oct 22 05:06 /usr/lib/libalpm.so.12.0.0

[/simterm]

Just with the libalpm.so.12.0.0 version, while package-query is looking for 11.

Solution #1 (wrong) – symlink

The very first idea is just to place a symlink to the new version during the upgrade process.

But that’s a terrible idea, especially for libraries.

Still, you can do that:

[simterm]

$ sudo ln -s /usr/lib/libalpm.so.12 /usr/lib/libalpm.so.11

[/simterm]

Solution #2 (correct) – re-build a package with makepkg

So, we need to re-install package-query to update its dependencies links, remove it:

[simterm]

$ sudo pacman -R package-query
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing package-query breaks dependency 'package-query>=1.8' required by yaourt

[/simterm]

Add dd options (see pacman) to ignore dependencies here:

[simterm]

$ sudo pacman -Rdd package-query

Packages (1) package-query-1.9-3

Total Removed Size:  0.09 MiB

:: Do you want to remove these packages? [Y/n] y
...

[/simterm]

Download the package-query package from its AUR’s repository:

[simterm]

$ git clone https://aur.archlinux.org/package-query.git
$ cd package-query/

[/simterm]

Build and install with the makepkg (-i, --install):

[simterm]

$ makepkg -si
...
==> Installing package package-query with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...
Packages (1) package-query-1.10-1

Total Installed Size:  0.07 MiB

:: Proceed with installation? [Y/n] y
...

[/simterm]

Check again with the ldd:

[simterm]

$  ldd /usr/bin/package-query | grep libalpm.so
        libalpm.so.12 => /usr/lib/libalpm.so.12 (0x00007fb7b6cab000)

[/simterm]

Re-run the upgrade:

[simterm]

...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating icon theme caches...
(3/3) Updating the desktop file MIME type cache...
No database errors have been found!

[/simterm]

Done.