Arch Linux: fixing the “yay: error while loading shared libraries: libalpm.so.13” error

By | 03/17/2024
 

After the latest Arch Linux upgrade, Yay reported the following error:

yay: error while loading shared libraries: libalpm.so.13: cannot open shared object file: No such file or directory

First, let’s check if we have the libalpm library file, and which version:

$ sudo find / -type f -name "*.so*" | grep libalpm
/usr/lib/libalpm.so.14.0.0

So, we have the libalpm.so.14, while Yay wants the old, 13 version.

The first way to fix, is just create a symlink:

$ sudo ln -s /usr/lib/libalpm.so.14.0.0 /usr/lib/libalpm.so.13

But although it’s a working solution, it’s always better to fix without such a “dirty hacks”.

So, what we can do, is to re-build and re-install Yay from the source. In this way, it will use the new libalpm.

Install Git and base-devel package:

$ sudo pacman -S git base-devel

Clone Yay’s repository, build and install it with the makepkg, which will use the PKGBUILD with a “description” how to build and install the package.

And in the PKGBUILD, we already have the “GOFLAGS="${GOFLAGS} $(pacman -T 'libalpm.so=14-64')" defined.

So, clone the repository, and run makepkg with the -s (--syncdeps – install dependencies) and -i (--install – install the built package with pacman):

$ git clone https://aur.archlinux.org/yay.git
$ cd yay/
$ makepkg -si

And Yay is working now:

$ yay --help
Usage:
    yay
    yay <operation> [...]
    yay <package(s)>
...

Done.