I experienced an error message recently while trying to install snapd on Arch Linux – “Pacman is currently in use, please wait..”. This would keep showing indefinitely:
....
==> Leaving fakeroot environment.
==> Finished making: snapd 2.51.4-1 (Mon Aug 30 18:22:36 2021)
==> Installing package snapd with pacman -U...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
==> Pacman is currently in use, please wait...
A reboot on the server couldn’t resolve the issue. After an informed troubleshooting I discovered the issue is related to Pacman database lock.
$ ls /var/lib/pacman/db.lck
The db.lck file exists to ensure that only one program can run updates or package installation at a time. This prevent s conflicts in package installation, interrupted installations/updates or partial updates in the system.
If the file exists, you need to remove it since it prevents pacman from creating a new lock as it executes.
But before deleting the database lock, confirm there are no other programs trying to update or install anything:
sudo ps aux | egrep -i 'yay|pacman|yaourt'
An identified process can be killed manually using kill command:
sudo kill -9 <pid>
Once you confirm no process executed by an individual or via automation scripts, you can safely delete the file:
sudo rm /var/lib/pacman/db.lck
After that, running the installation of snapd package from previous build was successful:
$ makepkg -si
==> WARNING: A package has already been built, installing existing package...
==> Installing package snapd with pacman -U...
loading packages...
resolving dependencies...
looking for conflicting packages...
Packages (1) snapd-2.51.4-1
Total Installed Size: 55.81 MiB
:: Proceed with installation? [Y/n] y
(1/1) checking keys in keyring [########################################################################] 100%
(1/1) checking package integrity [########################################################################] 100%
(1/1) loading package files [########################################################################] 100%
(1/1) checking for file conflicts [########################################################################] 100%
(1/1) checking available disk space [########################################################################] 100%
:: Processing package changes...
(1/1) installing snapd [########################################################################] 100%
Optional dependencies for snapd
bash-completion: bash completion support
xdg-desktop-portal: desktop integration
:: Running post-transaction hooks...
(1/3) Reloading system manager configuration...
(2/3) Arming ConditionNeedsUpdate...
(3/3) Reloading system bus configuration...
We hope this short guide has been helplful in fixing an issue relating to Pacman db.lck.
Tags:
- Fix unable to lock database in Pacman / Yaourt / Yay
- Fix could not lock database in Pacman / Yaourt / Yay
- Fix Pacman is currently in use, please wait
- Fix /var/lib/pacman/db.lck issues in Pacman
More guides on Arch Linux based distributions: