Arch Linux: fixing the “yay: error while loading shared libraries:” error

By | 03/17/2024

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

yay: error while loading shared libraries: 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

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

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

$ sudo ln -s /usr/lib/ /usr/lib/

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 '')" 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
$ cd yay/
$ makepkg -si

And Yay is working now:

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