Error failed to synchronize all databases unable to lock database

This brief guide describes how to fix "unable to lock database" error in Arch Linux, EndeavourOS and Manjaro Linux.

The other day, I was about to update my Arch Linux system. When I try to update the system, I encountered with «unable to lock database» error in Arch Linux. I could not install or remove any packages.

Here is the command that I entered to update my Arch Linux system:

# pacman -Syu

And, It returned the following error:

:: 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
Fix unable to lock database error in Arch linux
Fix unable to lock database error in Arch linux

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.

26 comments

Deepak
August 11, 2018 — 8:11 am

hey m unable to delete db.lck file. it showing even cant open.
plz help me.


Reply

sk
August 11, 2018 — 10:30 am

If your user has sudo permissions, you can definitely delete that file.


Reply

Alessandro
December 14, 2018 — 10:13 pm

Thank you, this article is helpful!


Reply

I use arch btw…
February 15, 2019 — 6:25 am

Excellent work! My Manjaro install didn’t show the location of the lock file, so thanks for the guide!


Reply

islamux
June 30, 2019 — 6:58 pm

Thank you , it’s helpful.


Reply

mahi
July 22, 2019 — 1:21 am

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


Reply

Sebastian
September 27, 2019 — 12:39 am

Thank you, that brought my system back!


Reply

jes
July 27, 2021 — 10:22 pm

Thanks a lottttt man . It workssss


Reply

IgorT
November 4, 2019 — 10:56 pm

Thank you sir!


Reply

Jesus Hernandez
December 15, 2019 — 7:57 pm

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!


Reply

annonoymous
March 11, 2020 — 6:24 am

THANK YOU SO MUCH IVE BEEN STRUGGLING WITH THIS FOR HOURS 🙂


Reply

Manish
March 20, 2020 — 10:28 pm

$ 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
$


Reply

sk
March 21, 2020 — 11:43 am

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.


Reply

Harsh Sanmukhani
April 22, 2020 — 3:01 pm

thanks it works for me…. 🙂


Reply

Mohammed
May 23, 2020 — 7:17 am

Thank you so much it works


Reply

Yash
July 12, 2020 — 6:31 pm

I got error : failed retrieving file core.db


Reply

sk
July 13, 2020 — 11:24 am


Reply

IMM
August 26, 2020 — 11:29 am

Hey. I use ‘Thunar Root’ to open ‘/var/lib/pacman/’ then I delete ‘db.lck’
It works for me
Hope this help


Reply

Kunle Apata
August 8, 2021 — 10:05 am

Please how do you use Thunar root to delete the lock files.
Thank you.


Reply

sk
August 8, 2021 — 6:27 pm

Hi Kunle,

Open Terminal and run the following command to open Thunar file manager as root:

pkexec thunar

Browse the file location and delete it normally. Please make sure you have selected the correct file name before deleting it.


Reply

Fruitser
August 15, 2022 — 10:45 am

I just used the pacman GUI to update the mirrors and it fixed it for me. I think it had something to do with the fact that my internet failed right when i was last updating the mirrors.


Reply

Moein from iran
September 27, 2020 — 2:26 am

thank you a lot


Reply

btw
November 10, 2020 — 4:46 pm

Thx 😀 <3


Reply

Matthew
November 6, 2021 — 7:45 am

No such file or directory error cannot remove help


Reply

sk
November 6, 2021 — 11:32 am

Share the output of the following command:
sudo pacman -Syu


Reply

Sami
February 19, 2022 — 4:16 am

Thanks, it worked.


Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

avatar

  • AlexGanter
  • 29 февраля 2020, 16:57

sudo rm /var/lib/pacman/db.lck

И попробуйте обновить.

А эта команда удаляет неисправные базы данных:

sudo rm -f /var/lib/pacman/sync/*

Последний раз редактировалось 29 февраля 2020, 17:00

avatar

  • AlexGanter
  • 29 февраля 2020, 18:36

У вас точно проблема с интернетом, так как опять пишет об истечении времени, доступности серверов.

Возьмите мой рабочий mirrorlist, скопируйте с заменой в /etc/pacman.d/ и попробуйте обновить.

Последний раз редактировалось 29 февраля 2020, 18:43

avatar

  • автор gitineg859
  • 29 февраля 2020, 18:50

Странно, ведь даже на заднем фоне видно, что сайт форума вполне загрузился c нормальной скоростью. Даже команда ping, на недоступные сервера показывает, что соединение есть.Раньше ставил Manjaro, всё было нормально. Но теперь такие вот проблемы. Видно придётся остаться на Ubuntu. Спасибо за помощь)

Последний раз редактировалось 29 февраля 2020, 18:51

avatar

  • AlexGanter
  • 29 февраля 2020, 18:56

Так вы в реале попробуйте загрузится с флэшки, в кривых настройках сети виртуалки манжаро не виновата)
В реальности всё работает.

Последний раз редактировалось 29 февраля 2020, 18:57

avatar

  • автор gitineg859
  • 29 февраля 2020, 19:05

Так говорил ведь, грузился и в реале с флешки, и с виртуалки. Также ставил на жд, ошибки те же… Даже пробывал несколько устройств, мало ли, но ошибка та же. Месяц назад скачивал 18 версу, поставил и впервые столкнулся с этой проблемой, тогда я забил, подумав что образ битый, снова поставив ubuntu. Скачал вот, недавно 19, но проблема не ушла.

avatar

  • AlexGanter
  • 29 февраля 2020, 19:24

У вас же KDE.
Для root доступа сделайте:
Завершить сеанс->Сменить пользователя(справа иконка).
Пользователь:
root
вводите пароль

Последний раз редактировалось 29 февраля 2020, 19:25

avatar

  • автор gitineg859
  • 29 февраля 2020, 20:04

Верно, кеды ставил. Попробывал кинуть файлы, которые вы давали и всё заработало) Спасибо за помощь! Забавно, что изначально этих файлов не было

If you are facing below errors when you upgrading Manjaro linux or updating any software package, don’t worry the below list of commands will solve your headache issue. Then you can do upgrade or update anything on your Manjaro box…to keep smaile..)

1) “Unable to lock database” Error

When downloading and installing software from the repositories on manjaro linux you will get this error message due to database lock file, which was created by default to ensure currently installation process is going on. If more then one attempt happen you will get this kind of error message. If so, just remove the lock file and go ahead.

# Unable to lock database - Error #
[email protected] [~]# sudo pacman -Syu
:: 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

# Unable to lock database - Solution #
[email protected] [~]# rm -Rf /var/lib/pacman/db.lck

2) error: failed retrieving file ‘core.db’

If the mirror files don’t have the proper mirror server list (any of the mirror server listed) which is lead to get the above error message. Just do updage the mirror server list once again to get solve the issue

# error : failed retrieving file 'core.db'
[email protected] [~]# sudo pacman -Syu
:: Synchronizing package databases...
error: failed retrieving file 'core.db' from ftp.lug.ro : Resolving timed out after 10518 milliseconds
error: failed retrieving file 'core.db' from mirror.dacentec.com : Resolving timed out after 10519 milliseconds
error: failed retrieving file 'core.db' from manjaro.mirrors.uk2.net : Resolving timed out after 10517 milliseconds
error: failed retrieving file 'core.db' from mirror.yandex.ru : Resolving timed out after 10516 milliseconds
error: failed retrieving file 'core.db' from repo.manjaro.org.uk : Resolving timed out after 10517 milliseconds
error: failed retrieving file 'core.db' from ftp.lysator.liu.se : Resolving timed out after 10516 milliseconds
error: failed retrieving file 'core.db' from mirror.catn.com : Resolving timed out after 10516 milliseconds
error: failed retrieving file 'core.db' from mirror.jmu.edu : Resolving timed out after 10516 milliseconds
error: failed retrieving file 'core.db' from vm1.sorch.info : Resolving timed out after 10515 milliseconds
error: failed retrieving file 'core.db' from mirror.zetup.net : Resolving timed out after 10515 milliseconds
error: failed retrieving file 'core.db' from mirror3.layerjet.com : Resolving timed out after 10514 milliseconds
error: failed retrieving file 'core.db' from manjaro.mirror.serversaustralia.com.au : Resolving timed out after 10514 milliseconds
.
.
# Solution : failed retrieving file 'core.db'
[email protected] [~]# pacman-mirrors -g
:: Querying servers, this may take some time...
Africa
-> 2.507 http://manjaro.mirror.ac.za/stable/$repo/$arch
-> 1.583 http://mirror.is.co.za/mirrors/manjaro.org/stable/$repo/$arch
Australia
-> 1.571 http://mirror.ventraip.net.au/Manjaro/stable/$repo/$arch
-> 1.237 http://manjaro.mirror.serversaustralia.com.au/stable/$repo/$arch
.
.

3) “Failed to commit transaction (invalid or corrupted package)” Error

Who ever developing the software package they have encrypted codes (signature keys) to avoid the malicious transaction whenever anyone trying to download the software packages from repositories. During the installation process, once any software packages have been downloaded, your system will first check their signature keys to ensure that they are authentic prior to actually installing them. If a signature key cannot be verified you will get above error message. If so, use the below command to download necessary signature key files to get solve the issue.

# error : invalid or corrupted package'
[email protected] [~]# sudo pacman -Syu
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 community is up to date
 multilib is up to date
:: Some packages should be upgraded first...
resolving dependencies...
looking for conflicting packages...

Packages (1) manjaro-system-20150804-1
:: Starting full system upgrade...
.
.
Total Download Size:    319.92 MiB
Total Installed Size:  3452.33 MiB
Net Upgrade Size:       217.86 MiB
.
.
:: Proceed with installation? [Y/n] y
:: Retrieving packages ...
.
.
error: manjaro-printer: signature from "Bernhard Landauer " is marginal trust
:: File /var/cache/pacman/pkg/manjaro-printer-2015.06-2-any.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
error: os-prober: signature from "Bernhard Landauer " is marginal trust
:: File /var/cache/pacman/pkg/os-prober-1.66-1-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.

# Solution : invalid or corrupted package'
[email protected] [~]# pacman -S manjaro-keyring
resolving dependencies...
looking for conflicting packages...

Packages (1) manjaro-keyring-20150712-1

Total Installed Size:  0.06 MiB
Net Upgrade Size:      0.00 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%
(1/1) upgrading manjaro-keyring                    [######################] 100%
==> Appending keys from manjaro.gpg...
==> Locally signing trusted keys in keyring...
  -> Locally signing key 7C89F4D439B2BFACF425107B62443D89B35859F8...
  -> Locally signing key 5A97ED6B72418199F0C22B23137C934B5DCB998E...
  -> Locally signing key FAA6840E8C3FC7F89BEE0DC8AC7AB10BCB6CDD17...
  -> Locally signing key B4663188A692DB1E45A98EE95BD96CC4247B52CC...
usr/bin/pacman-key: line 609: printf: write error: Broken pipe
  -> Locally signing key 540DE7083B89314CF70EA6F0C1B1AD0DA80EBF3E...
  -> Locally signing key 35B4FF23EA9477582C2A0AF12B80869C5C0102A6...
  -> Locally signing key 1E7908935AAB9A00D6B47503363DFFFD59152F77...
  -> Locally signing key 77DC01C9971AC3C39A0626F72C089F09AC97B894...
  -> Locally signing key 74C2F2CC05A0AB7D859839938934292D604F8BA2...
  -> Locally signing key 39F0EC1AE50B37E5F3196F09DAD3B211663CA268...
  -> Locally signing key E4CDFE50A2DA85D58C8A8C70CAA6A59611C7F07E...
==> Importing owner trust values...
gpg: setting ownertrust to 4
==> Updating trust database...
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:  16  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: depth: 1  valid:  16  signed:  62  trust: 0-, 0q, 0n, 16m, 0f, 0u
gpg: depth: 2  valid:  60  signed:   5  trust: 60-, 0q, 0n, 0m, 0f, 0u
gpg: next trustdb check due at 2015-12-14

Now, finally i can able to upgrade the system to latest version…keep smile…)

Понравилась статья? Поделить с друзьями:
  • Error failed to start network default
  • Error failed to setup chroot mnt
  • Error failed to set user interface authentication mode please modify the protocol first
  • Error failed to set phone to flashmode phoenix
  • Error failed to send host log message virtualbox