Fix the Yay libalpm Error: Why It Happens and How to Recover in Minutes

How to fix the yay "error while loading shared libraries: libalpm.so" message after a pacman upgrade, why it happens and how to stop it catching you out again.

Fix the Yay libalpm Error: Why It Happens and How to Recover in Minutes

Yayarch sees one error message more than any other from yay users: yay, error while loading shared libraries, libalpm.so followed by a number, cannot open shared object file, no such file or directory. It usually appears straight after a large system upgrade, and it can look as though yay, or even the whole system, is broken. It is neither. This article explains in plain terms what the message means, how to fix it in a few minutes and how to avoid being caught out next time.

What libalpm is

Pacman, Arch's package manager, is built around a library called libalpm, the Arch Linux Package Management library. Pacman itself is a front end to that library. Other tools that need to read or change the package database, including yay, link against libalpm too, so that they behave consistently with pacman.

Like most shared libraries, libalpm has a version number in its file name, known as its soname. When the library changes in ways that are not backward compatible, the soname number goes up. Programs built against the old number will look for the old file and refuse to start if it has gone.

Why the error appears after an upgrade

When a new major version of pacman is released, it often comes with a new libalpm soname. For example, the arrival of pacman 7 in 2024 moved the library from libalpm.so.14 to libalpm.so.15, and later pacman releases have moved it on again.

Pacman upgrades itself and the library together, so pacman keeps working. Yay, however, is an AUR package that was compiled on your machine, or downloaded as a binary, against the old library. The upgrade removes the old library file, and the next time you run yay it cannot find it. The result is the familiar message naming the old soname.

Nothing is damaged. Your packages, your pacman database and pacman itself are all fine. Yay simply needs rebuilding against the new library.

The quick fix

Because pacman still works, you can rebuild yay by hand exactly as you did when you first installed it. Work in your home directory as your normal user.

sudo pacman -S --needed git base-devel
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Building from the source package guarantees that yay links against the libalpm currently on your system. When makepkg finishes and pacman installs the package, check the result.

yay --version

The output should show the new libalpm version. You can now delete the folder you cloned and carry on with a normal yay upgrade.

Using yay-bin instead

The precompiled yay-bin package is quicker because it skips compilation.

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

There is a catch. Yay-bin contains a binary built by the yay project, and that binary was linked against whichever libalpm was current when it was built. If the AUR package has not yet been updated with a binary built for the new library, installing it will simply reproduce the same error. If that happens, use the source package above. Once the maintainer publishes a rebuilt binary, yay-bin will work again.

When the old yay cannot be removed

Some people try to remove the broken yay first and run into confusion. You do not need to remove it. Installing the freshly built package replaces the old one, because pacman treats it as an upgrade or reinstall. If you are switching between yay and yay-bin, pacman will ask whether to replace one with the other, since each conflicts with and provides the other. Answer yes.

If for some reason you want to remove it explicitly, sudo pacman -Rns yay or sudo pacman -Rns yay-bin works normally, because pacman itself is unaffected.

A temporary workaround to avoid

On forums you may see advice to create a symbolic link so that the old library name points to the new file. This can make yay start, but it is a poor idea. The soname changed precisely because the library is no longer compatible. A program built for the old version may misbehave in subtle ways when talking to the new one, and you are working with your package database, which is the last place you want subtle errors. Rebuild instead. It takes a minute or two.

Other programs with the same problem

Yay is not the only AUR program that links against libalpm. Package browsers, update notifiers and some system information tools do too. After a pacman soname change, any of them may show the same error. The fix is the same: rebuild them. Once yay works again, you can do this with a forced rebuild.

yay -S --rebuild package-name

To find which installed packages depend on libalpm, check pacman's required-by list for the pacman package with pacman -Qi pacman.

On Arch Linux ARM

Arch Linux ARM sometimes upgrades pacman later than the main Arch project. There have been times when yay-bin's ARM binaries were built against a different libalpm from the one installed on ARM systems, producing the same error in reverse. Building the source yay package locally on the ARM device avoids this, because it always links against whatever library is actually present.

On distributions that package yay

On Manjaro, CachyOS and others that ship yay in their own repositories, the distribution rebuilds yay when it updates pacman. If you see the error there, it usually means one part of the update has arrived before the other. Running a full system upgrade again a little later often resolves it. If you are in a hurry, building yay from the AUR works as a stopgap, though you may want to return to the repository package once it catches up.

How to avoid being surprised next time

You cannot prevent pacman from changing its library version, but you can make the moment painless.

  • Read the Arch news before large upgrades. Major pacman releases are usually mentioned.
  • When a full upgrade includes a new major pacman version, expect to rebuild yay afterwards.
  • Keep git and base-devel installed so that a manual rebuild is always possible.
  • Know the four commands above by heart, or keep them somewhere handy.

Some users rebuild yay immediately after any pacman upgrade as a matter of routine. That is harmless and guarantees yay is always linked correctly.

pacman itself reports a missing libalpm

If pacman, not yay, shows the error, the problem is more serious, usually an interrupted upgrade that left pacman and its library out of step. Recovery typically involves the statically linked pacman-static package or booting from installation media. This is rare, and it is not caused by yay.

Database lock errors

An error saying the database is locked means another package operation is running or was interrupted. Check that nothing else is using pacman before removing the lock file. Yay 13.1 is better at cleaning up locks after interrupted operations.

Understanding the error message line by line

It helps to read the message slowly, because every part of it tells you something. The first word is the name of the program that failed to start, which is yay. The phrase "error while loading shared libraries" comes from the system's dynamic linker, the component that connects a program to the libraries it needs at launch time. It is not a yay error at all, which is why yay cannot print anything more helpful.

Next comes the library name, such as libalpm.so.15. The number at the end is the soname version the program was built to expect. Finally, "cannot open shared object file: No such file or directory" means the linker searched the standard library folders and found no file with that exact name.

Put together, the message says: yay was built for libalpm version 15, and version 15 is no longer on this system. Once you can read it that way, the fix is obvious, and you will recognise the same pattern in errors from any other program after a library upgrade.

Checking which libalpm you have now

If you want to confirm the diagnosis before rebuilding, list the library files pacman installed.

ls /usr/lib/libalpm.so*

You will see the current library file and its symbolic links. If the number shown is higher than the one in yay's error message, you have confirmed that yay simply needs rebuilding. You can also run pacman -V, which prints both the pacman version and the libalpm version it uses.

Why rebuilding is the right fix

Some users wonder why Arch does not keep the old library around for compatibility. The answer lies in how Arch works. It ships one current version of each library and rebuilds the packages that depend on it. Programs in the official repositories are rebuilt by Arch's packagers at the same time as the library changes, so they never break. AUR packages are built by you, on your machine, so rebuilding them is your part of the same process.

Seen this way, the libalpm error is not a fault. It is the normal rolling-release model asking you to do the one job the official packagers cannot do on your behalf.

A short checklist for the next pacman release

When you notice a new major pacman version in your upgrade list, a little preparation turns the error into a non-event.

  • Let the full upgrade finish completely before doing anything else.
  • Run yay --version. If it fails, you know immediately what to do.
  • Rebuild from the source yay package in your home directory.
  • Rebuild any other AUR tools that report the same error.
  • Run one more full yay upgrade to confirm everything is in step.

Frequently asked questions

Why does yay say libalpm.so cannot be opened?

Because pacman was upgraded to a version with a new libalpm soname, and yay was built against the old one. Rebuilding yay fixes it.

Will this error damage my system?

No. Pacman and your installed packages are unaffected. Only yay and other programs linked to the old library stop working.

Should I downgrade pacman to fix it?

No. Downgrading pacman creates a partial upgrade and can cause real problems. Rebuild yay instead.

Why did yay-bin not fix the error?

Its binary may still be built against the old library. Use the source yay package until yay-bin is updated.

Do I need to reinstall my AUR packages?

Only those that link against libalpm. Most AUR packages are unaffected.

How long does the fix take?

A few minutes on a typical computer. Building from source takes slightly longer than using yay-bin.

Conclusion

The yay libalpm error looks dramatic but has a simple cause and an equally simple cure. A pacman upgrade changed the library's version, and yay needs rebuilding to match. Clone the yay package from the AUR, run makepkg, confirm the version and carry on. Avoid symbolic link workarounds and pacman downgrades, expect the error after major pacman releases, and it will never cost you more than a few minutes.