error: could not open file /var/lib/pacman/local/.../{desc,files,mtree}: No such file or directory

faq
#1

Your local package database and/or metadata may become corrupted if an update process is interrupted, for example if you hard power off during an update.

Metadata corruption will generally manifest in a message similar to:

error: could not open file /var/lib/pacman/local/$pkgname-$pkgver-$pkgrel/desc: No such file or directory
error: could not open file /var/lib/pacman/local/$pkgname-$pkgver-$pkgrel/files: No such file or directory
error: could not open file /var/lib/pacman/local/$pkgname-$pkgver-$pkgrel/mtree: No such file or directory

during a package operation (install, update, etc.).

Note: $pkgname is the package name, $pkgver the version, $pkgrel the release

Fixing this issue involves manually creating a replacement file to allow package operations to continue, then putting the correct metadata back in place.

Step 1

Note the package for which metadata has been corrupted. It's the $pkgname part of the path.

Step 2

Create a temporary replacement file for any files which are currently missing, e.g.:

sudo touch /var/lib/pacman/local/$pkgname-$pkgver-$pkgrel/{desc,files,mtree}

This path must exactly match the text from the error message. For example, for

error: could not open file /var/lib/pacman/local/smbclient-4.10.2-0/desc: No such file or directory

you must type:

sudo touch /var/lib/pacman/local/smbclient-4.10.2-0/desc

Step 3

Reinstall the package.

The replacement file is blank and must be replaced with the correct content. The easiest way to do this is simply reinstall the package:

sudo pacman -S $pkgname

where $pkgname is the package you noted down previously.

For example, for

error: could not open file /var/lib/pacman/local/smbclient-4.10.2-0/desc: No such file or directory

you must type:

sudo pacman -S smbclient

If you see errors about other missing metadata files simply repeat Step 2.

Step 4

Continue with your life and be glad you're running Linux where an interrupted update doesn't simply kill your OS and require a reinstallation (unlike another OS I could mention...).

9 Likes