2 minutes
Arch WSL crashes due to Pacman Lock Files
After a recent update, my Arch WSL distribution stopped starting correctly.
tl;dr
# 1) Make sure no Pacman process is running
ps aux | grep -i pacman
# 2) Remove lock files
sudo rm -f /var/lib/pacman/db.lck
sudo rm -f /var/cache/pacman/pkg.lock
# 3) Re-sync databases
sudo pacman -Syy
# 4) Upgrade the system
sudo pacman -Syu --noconfirm
Error message
Schwerwiegender Fehler Fehlercode: Wsl/Service/E_UNEXPECTED
[Verarbeitung des Prozesses mit Code 4294967295 (0xffffffff) beendet]
Sie können dieses Terminal jetzt mit STRG+D schließen oder zum Neustart die EINGABETASTE drücken.
Roughly translated:
Serious error Error code: Wsl/Service/E_UNEXPECTED
[Process with code 4294967295 (0xffffffff) terminated] You can now close this terminal with CTRL+D or press ENTER to restart.
The “unable to lock database” problem occurs because Pacman left behind a lock file during its last run (or while another process was running simultaneously). As long as this file exists, Pacman assumes that another package manager is already active and terminates.
Step-by-step fix
1 Check whether a Pacman process is still running
ps aux | grep -i pacman
If you see a running pacman -Syu or pacman -Sy process, wait for it to finish or stop it carefully.
2 Remove lock files
Run this only if no Pacman process is active:
sudo rm -f /var/lib/pacman/db.lck
sudo rm -f /var/cache/pacman/pkg.lock
/var/lib/pacman/db.lck: locks the package database/var/cache/pacman/pkg.lock: optionally locks the package cache (less common)
3 Re-sync package databases
Sometimes a partially completed upgrade gets stuck in the /var/lib/pacman/local directory. The safest way is to synchronize the database:
sudo pacman -Syy
4 Run the system upgrade again
sudo pacman -Syu --noconfirm
If you want to review prompts interactively, remove --noconfirm.
If it still fails
Check package database integrity
sudo pacman -Dk
Clean package cache
sudo pacman -Sc
Reinstall Pacman (last resort)
sudo pacman -S pacman
Read other posts