Published on

pacman Error Solving the db.lck File Issue

Authors
  • avatar
    Name
    hwahyeon
    Twitter

While updating packages on Manjaro, I encountered the following error:

Fehler: Keine Datenbank konnte synchronisiert werden (Kann Datenbank nicht sperren)
Hinweis: ... /var/lib/pacman/db.lck entfernen

Translated from German:

Error: Could not synchronize database (could not lock database)
Note: Remove the file `/var/lib/pacman/db.lck`

What is db.lck?

pacman uses the package database located under /var/lib/pacman/.
To prevent corruption from multiple processes modifying it at the same time, pacman creates a lock file called db.lck when starting an operation.

  • Created automatically when pacman or pamac runs
  • Removed automatically when the process ends normally
  • If the process is interrupted, the file may remain and pacman assumes another process is still running

Causes

  • pacman/pamac is actually still running
  • A previous process was interrupted, leaving only the db.lck file (in my case).

How to Fix

  1. Check for running processes

    ps -e | grep -E 'pacman|pamac'
    

    → If running, wait or close it. If pacman is actually working and you remove the lock, you may corrupt the database.

  2. Remove the lock file only if nothing is running

    sudo rm -f /var/lib/pacman/db.lck
    
  3. Retry the update

    sudo pacman -Syu