0

I can't sync my archlinux. When I try to use pacman it get this:

ThinkPad-de-Micael_Andre% sudo pacman -Syu
[sudo] password for dmicaelandre:
Sorry, try again.
[sudo] password for dmicaelandre:
:: 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 update archlinuxfr (unable to lock database)
error: failed to update blackarch (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

Apparently pacman is in use by another process. How can I get pacman to work?

Chindraba
  • 1,478
Micael André
  • 375
  • 3
  • 7
  • 14

1 Answers1

5

When a program says that something else, including another instance of itself, has a resource locked, the first thing to check is if something is really running and using that resource. After you verify that nothing is really using it you can remove the lock.

Often the program will tell you which process is using the resource, or tell you how to remove the lock. In this case the package manager database was locked with the db.lck file, and the error message said to execute remove /var/lib/packman/db.lck.

The cause is often that the last time the program was used it didn't end correctly and remove the lock itself. This could be an error that triggered and abort, or the system could have terminated the process without giving it the opportunity to clean up. The system could have frozen, or shut down, or lost power, as well. Any of these events could cause the resource lock to remain in the file system, and require manual removal.

Of course, always check for a live process before removing any lock files.

Chindraba
  • 1,478