修复 Arch Linux 中的“无法锁定数据库”错误
前几天,我正准备更新我的 Arch Linux 系统。当我尝试更新系统时,我在 Arch Linux 中遇到了“无法锁定数据库”错误。我无法安装或删除任何软件包。本简短指南解释了如何修复 Arch Linux 及其变体(例如 EndeavourOS 和 Manjaro Linux)中的“无法锁定数据库”错误。
“无法锁定数据库”问题的根本原因
Arch Linux 中的“无法锁定数据库”错误通常发生在另一个进程已经在访问软件包数据库时,例如软件包管理器或软件更新工具。此错误会阻止您执行某些包管理操作。
Pacman 创建一个名为 /var/lib/pacman/db.lck 的锁定文件,以确保在任何给定时间只有一个实例正在修改系统包数据库,从而防止潜在的腐败。
要解决此问题,请验证当前是否正在运行任何其他包管理器或软件更新程序。有时,您可能不小心打开了包管理器或更新工具的多个实例。关闭所有当前正在运行的包管理工具,或者最好等待它们完成操作。
如果没有活动的包管理进程,您可以手动删除锁定文件,如以下步骤所示。
修复 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修复 Arch linux 中无法锁定数据库错误
Linux 发行版的美妙之处在于有时它们偶尔会显示错误消息以及明确的解决方案。
正如您在上面的输出中看到的,它显示:“..您可以删除/var/lib/pacman/db.lck”。
所以,我只是用命令删除了上述文件:
sudo rm /var/lib/pacman/db.lck瞧!有效。然后我就可以毫无问题地更新、安装和删除。
sudo 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-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希望这可以帮助。
