MSYS2-packages: MSYS2 pacman -Sys Unable to lock database
To start Code and Compile C++, I 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 reference. Also, the Directory image is shared for reference.
Note:
- No anti-virus installed. Just regular old Windows Defender.
- Re-installed it 3 times in different locations but no change in result.
- All installations were made as admin.
$ 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 ~
$
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (4 by maintainers)
I completely solved this problem by running msys as administrator.
Yes, in the detail install guide: https://www.msys2.org/wiki/MSYS2-installation/ They can be installed or extracted to any place on your computer, but you MUST use folder names that consist of only ascii characters and no spaces (also it makes good sense to put it in a path that doesn’t use many characters due to PATH_MAX being 260; C:\msys32 or C:\msys64 is ideal) my fault is the space in the folder name.
I would delete the whole msys64 folder. Open a command shell as an Administrator. Create a C:\msys64 directory. Open Windows Security and add the C:\msys64 directory to the exceptions list. This will stop Windows Defender from scanning the directory and blocking the programs. run the installer as an Administrator. You can then update as per the documentation on the website.
Solved this issue by giving my user the
Full Control
permission over the directory.I tried a bit different method and it seems to work. It looks like this software doesn’t install well in drives except for the C drive. I uninstalled and deleted any residue folders of MSYS2. And re-installed it in C drive. It worked without any errors.
msys2 programs do not need to run as administrator. Removing the
/var/lib/pacman/db.lck
is the only solution.I have the same problem but I solve this problem by running the MSYS as an administrator
I met the same problem, finally I found msys64 folder must be created at the root of the disk, such as c:\msys64 or d:\msys64.
I am using msys2 from both D: and F: drives. Testing purposes 😎
Try this one, I think that solved my issue. https://sourceforge.net/projects/mingw/