MinGW pacman -Sys Unable to lock database

Viewed 1809

To start Code and Compile C++, must install a compiler. For my case, it is MSYS2 through which MinGW is available. According to the installation guild mentioned on the website, I installed the software without any errors. Now I was supposed to update the package database and base packages by entering pacman -Sys but it has shown an error error: failed to synchronize all databases (unable to lock database)

After searching online for a solution I found that deleting/removing the db.lck will work, for that, I used this command rm /var/lib/pacman/db.lck but it showed another error. Right now there is no solution to this on the internet. I've also pasted the terminal output of MSYS2 MSYS for refernce.

$ pacman -Sys
:: Synchronizing package databases...
error: failed to synchronize all databases (unable to lock database)

VIRAT@DESKTOP-97BS0AB MSYS ~
$ rm /var/lib/pacman/db.lck
rm: cannot remove '/var/lib/pacman/db.lck': No such file or directory

VIRAT@DESKTOP-97BS0AB MSYS ~
$ pacman -S --needed base-devel mingw-w64-x86_64-toolchain
error: failed to init transaction (unable to lock database)
error: could not lock database: Permission denied

VIRAT@DESKTOP-97BS0AB MSYS ~
$ pacman -Su
error: failed to init transaction (unable to lock database)
error: could not lock database: Permission denied

VIRAT@DESKTOP-97BS0AB MSYS ~
$
2 Answers

As I found there 2 solutions for this error. Try both :

Solution : 1

  1. C:\Users\your_account_name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\MSYS2 64bit

  2. Run "MSYS2 MSYS" as administrator

  3. Run the command : pacman -Syu

Solution - 2 :

  1. C:\msys64\var\lib\pacman ( Go to the downloaded folder)

  2. Delete the "db.lck" file


RESOURCES :

For solution 1 : Mr. Padro's (https://stackoverflow.com/users/18910613/pedro) solution helped me.

For solution 2 https://www.reddit.com/r/archlinux/comments/nvrny2/pacman_error_failed_to_synchronize_all_databases/

Try to run MSYS app under administrator privilege... worked for me

Related