This quick guide helps you to fix the common pacman failed to update core error in Arch Linux, Manjar, and other Linux.
pacman is a package manager used primarily in Arch Linux based distributions. It is used in vanilla Arch Linux, Manjaro as well. If you use Arch Linux a lot you must have encountered the following errors and already know how to fix them. However, this quick guide is for beginners who are not aware of the problem and why it happens, with a fix as well.
This guide fixes the following errors
error: failed to update core (unable to lock database)
error: failed to update extra (unable to lock database)
error: failed to update community (unable to lock database)
Why and when pacman Failed to Update Core occurs
This error comes when you run pacman to update or sync your system by running commands like
pacman -Syy or
When pacman starts to alter the package database during sync or installation it creates a lock file at
/var/lib/pacman/db.lck. This lock file prevents any other pacman instance or applications from accessing the package database by creating an exclusive lock.
Trouble arises when you interrupt pacman midway, via a reboot, shutdown, or any other event. The commands not abe to complete and release the lock. So next time you attempt to access the package database the lock file prevents it.
How to Fix
The fix is super easy. However, it requires root or admin privileges. Open a terminal and run the below command to manually remove the file.
sudo rm /var/lib/pacman/db.lck
Once done, you can safely perform the pacman command which caused the error.
That’s it. I hope this quick tip helps you to fix the error.