The other day, I was about to update my Arch Linux system. When I issued the following command to update Arch Linux server, it showed an error, and won't let me to install any package or remove any package.
# pacman -Syu
Sample output:
:: Synchronizing package databases... 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) error: failed to update multilib (unable to lock database) error: failed to synchronize any databases error: failed to init transaction (unable to lock database) error: could not lock database: File exists if you're sure a package manager is not already running, you can remove /var/lib/pacman/db.lck
The beauty of Linux distros is sometimes they will the explicitly display the solution along with the error message. As you can see in the above output, it says: "..you can remove /var/lib/pacman/db.lck".
So, I simply deleted the aforementioned file with command:
$ sudo rm /var/lib/pacman/db.lck
Voila! It worked. I can then able to update, install and remove without any problems.
$ pacman -Syu
Sample output:
:: Synchronizing package databases... core 122.8 KiB 162K/s 00:01 [######################] 100% extra 1771.8 KiB 249K/s 00:07 [######################] 100% community 3.3 MiB 256K/s 00:13 [######################] 100% multilib 163.5 KiB 265K/s 00:01 [######################] 100% :: Starting full system upgrade... resolving dependencies... looking for conflicting packages... Packages (8) ca-certificates-mozilla-3.22-1 coreutils-8.25-1 curl-7.47.1-1 gcc-5.3.0-4 gcc-libs-5.3.0-4 libgcrypt-1.6.5-1 nano-2.5.2-1 pacman-mirrorlist-20160208-2 Total Download Size: 42.79 MiB Total Installed Size: 187.90 MiB Net Upgrade Size: 0.91 MiB :: Proceed with installation? [Y/n] y :: Retrieving packages ... gcc-libs-5.3.0-4-x86_64 12.7 MiB 261K/s 00:50 [######################] 100% coreutils-8.25-1-x86_64 2.1 MiB 262K/s 00:08 [######################] 100% ca-certificates-moz... 363.0 KiB 241K/s 00:02 [######################] 100% curl-7.47.1-1-x86_64 798.3 KiB 263K/s 00:03 [######################] 100% gcc-5.3.0-4-x86_64 26.1 MiB 247K/s 01:48 [######################] 100% libgcrypt-1.6.5-1-x... 403.5 KiB 244K/s 00:02 [######################] 100% nano-2.5.2-1-x86_64 407.0 KiB 262K/s 00:02 [######################] 100% pacman-mirrorlist-2... 5.3 KiB 408K/s 00:00 [######################] 100% (8/8) checking keys in keyring [######################] 100% (8/8) checking package integrity [######################] 100% (8/8) loading package files [######################] 100% (8/8) checking for file conflicts [######################] 100% (8/8) checking available disk space [######################] 100% :: Processing package changes... (1/8) upgrading gcc-libs [######################] 100% (2/8) upgrading coreutils [######################] 100% (3/8) upgrading ca-certificates-mozilla [######################] 100% (4/8) upgrading curl [######################] 100% (5/8) upgrading gcc [######################] 100% (6/8) upgrading libgcrypt [######################] 100% (7/8) upgrading nano [######################] 100% (8/8) upgrading pacman-mirrorlist [######################] 100% warning: /etc/pacman.d/mirrorlist installed as /etc/pacman.d/mirrorlist.pacnew
Hope this helps.
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Reddit | Facebook | Twitter | LinkedIn | RSS feeds
Have a Good day!!
19 comments
hey m unable to delete db.lck file. it showing even cant open.
plz help me.
If your user has sudo permissions, you can definitely delete that file.
Thank you, this article is helpful!
Excellent work! My Manjaro install didn’t show the location of the lock file, so thanks for the guide!
Thank you , it’s helpful.
now (21.07.2019) it does not(((
[… ~]$ sudo pacman -Syu
[sudo] password for …:
:: Synchronizing package databases…
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)
error: failed to update multilib (unable to lock database)
error: failed to synchronize all databases
EOF
Thank you, that brought my system back!
Thank you sir!
I just had the same problem but without it saying the solution you got at the buttom. I still tried running your command to delete that file and it worked. Thanks!
THANK YOU SO MUCH IVE BEEN STRUGGLING WITH THIS FOR HOURS 🙂
$ sudo rm /var/lib/pacman/db.lck
[sudo] password for xyz:
rm: cannot remove ‘/var/lib/pacman/db.lck’: No such file or directory
$ pacman -Syu
error: you cannot perform this operation unless you are root.
$ pacman -Syu
error: you cannot perform this operation unless you are root.
$ sudo rm /vr/lib/pacman/db.lck
rm: cannot remove ‘/vr/lib/pacman/db.lck’: No such file or directory
$
Check if your user is in sudoers list and then delete the file. There is a typo in this line – “/vr/lib/pacman/db.lck”. It is var, not vr.
thanks it works for me…. 🙂
Thank you so much it works
I got error : failed retrieving file core.db
It could be due to Arch Linux mirror problem. Choose a nearest working mirror and try again. Also check if you have enough space in /var directory. More details in this thread -> https://forum.manjaro.org/t/error-failed-retrieving-file-core-db-from-another-way-to-update/11534/11
Hey. I use ‘Thunar Root’ to open ‘/var/lib/pacman/’ then I delete ‘db.lck’
It works for me
Hope this help
thank you a lot
Thx 😀 <3