如何在Arch Linux中修复"无法锁定数据库"错误

时间:2020-03-21 11:44:34  来源:igfitidea点击:

如何修改 "unable to lock database"
前几天,我想要更新我的Arch Linux系统。
当我执行以下命令以更新Arch Linux服务器时,它显示出错,并且不会让我安装任何包或者删除任何包。

# 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

Linux Distrs的美有时它们将明确地显示解决方案以及错误消息。
正如我们在上面的输出中看到的那样,它说:"..你可以删除/var/lib/pacman/db.lck"。

因此,我只用命令删除了上述文件:

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

然后我可以在没有任何问题的情况下更新,安装和删除。

$pacman -Syu

示例输出:

:: 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-20150208-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