Failed to synchronize all databases (unexpected error); after pacnew overwrite

Hello everyone.

I went through my .pacnew files uing pacdiff. I tried to compare them as good as I could and for some of them I decided to overwrite the old files with the .pacnew files.
I can’t recall all of them, but I definitely replaced pacman.conf and pamac.conf

Now, when I try to sync my system, I get following error:

sudo pacman -Syu
:: Synchronizing package databases...
error: failed to synchronize all databases (unexpected error)

The error is not specified to GPGME or db.lck or something similar; that’s why I was not able to find a solution for me here in the forum, nor by googling it.

I get the same error using Pamac/PamacGUI.

What I tried so far:

  1. pacman-mirrors -c all and pacman-mirrors -f5
  2. refreshing keys by following these steps:
    https://wiki.manjaro.org/index.php/Pacman_troubleshooting#Errors_about_Keys

Normally I am using Mullvad-VPN, but this error persists with or without VPN enabled.

DE: XFCE
Kernel: 6.6.80-1 LTS

I was looking all day for a solution, but could not find any. Any help would be highly appreciated. Thanks

Some people are currently having the problem that the community.db is still in the pacman.conf. I imagine this might be the case for you, too.

Edit your /etc/pacman.conf and make sure your repo config part look like this

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.

[multilib]
Include = /etc/pacman.d/mirrorlist

You need to remove the following.

[community]
SigLevel = PackageRequired
Include = /etc/pacman.d/mirrorlist

Then in the terminal

sudo pacman-mirrors --fasttrack
sudo pacman -Syu

If you haven’t made any changes to pacman.conf, you can simply type the following in the terminal.

sudo cp /etc/pacman.conf /etc/pacman.conf.original
sudo cp /etc/pacman.conf.pacnew /etc/pacman.conf
sudo pacman-mirrors --fasttrack
sudo pacman -Syu

@admdb I already replaced pacman.conf with it’s .pacnew counterpart (I didn’t save the original); so the community repo is not in there anymore.

The error message is not specific for any repo. It shows everytime I try to sync or install anything:

sudo pacman -Syu
:: Synchronizing package databases...
error: failed to synchronize all databases (unexpected error)

Here is the full pacman.conf

#
# /etc/pacman.conf
#
# See the pacman.conf(5) manpage for option and repository directives

#
# GENERAL OPTIONS
#
[options]
# The following paths are commented out with their default values listed.
# If you wish to use different paths, uncomment and update the paths.
#RootDir     = /
#DBPath      = /var/lib/pacman/
#CacheDir    = /var/cache/pacman/pkg/
#LogFile     = /var/log/pacman.log
#GPGDir      = /etc/pacman.d/gnupg/
#HookDir     = /etc/pacman.d/hooks/
HoldPkg      = pacman glibc manjaro-system
#XferCommand = /usr/bin/curl -L -C - -f -o %o %u
#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
#CleanMethod = KeepInstalled
Architecture = auto

#IgnorePkg   =
#IgnorePkg   =
#IgnoreGroup =

#NoUpgrade   =
#NoExtract   =

# Misc options
#UseSyslog
Color
#NoProgressBar
CheckSpace
#VerbosePkgLists
ParallelDownloads = 4
DownloadUser = alpm
#DisableSandbox
#ILoveCandy

# By default, pacman accepts packages signed by keys that its local keyring
# trusts (see pacman-key and its man page), as well as unsigned packages.
SigLevel    = Required DatabaseOptional
LocalFileSigLevel = Optional
#RemoteFileSigLevel = Required

# NOTE: You must run `pacman-key --init` before first using pacman; the local
# keyring can then be populated with the keys of all official Arch and Manjaro Linux
# packagers with `pacman-key --populate archlinux manjaro`.

#
# REPOSITORIES
#   - can be defined here or included from another file
#   - pacman will search repositories in the order defined here
#   - local/custom mirrors can be added here or in separate files
#   - repositories listed first will take precedence when packages
#     have identical names, regardless of version number
#   - URLs will have $repo replaced by the name of the current repo
#   - URLs will have $arch replaced by the name of the architecture
#
# Repository entries are of the format:
#       [repo-name]
#       Server = ServerName
#       Include = IncludePath
#
# The header [repo-name] is crucial - it must be present and
# uncommented to enable the repo.
#

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.

[multilib]
Include = /etc/pacman.d/mirrorlist

# An example of a custom package repository.  See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

Any change after refreshing the list of mirrors?
sudo pacman-mirrors -f (for example)

@Nachlese No, the error persists. I refreshed the mirrors multiple times using different methods via pacman and pamacGUI

sudo pacman-mirrors -f5
sudo pacman-mirrors -i
sudo pacman-mirrors -c all

The mirrors have good latency and I tried different countries aswell.

When I do:
sudo pacman -Syu

I get:

sudo pacman -Syu
[sudo] password for jo: 
:: Synchronizing package databases...
 core is up to date
 extra                                                                           8.3 MiB  4.04 MiB/s 00:02 [################################################################] 100%
 multilib                                                                      143.1 KiB   325 KiB/s 00:00 [################################################################] 100%
:: Starting full system upgrade...
 there is nothing to do

It doesn’t tell you why it failed? Or on which database?

That’s the confusing part and why I am lost here. It doesn’t say anything. The error I posted earlier is the exact output.

It looks like something is prohibiting it before any action.

Hmm

that is indeed not exactly helpful

You could try to run the command with the -v switch for more verbose output.
Perhaps that will yield something to go on?

sudo pacman -Syuv
[sudo] password for jo: 
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/  
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/  
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : None
:: Synchronizing package databases...
 core is up to date
 extra is up to date
 multilib is up to date
:: Starting full system upgrade...
 there is nothing to do
1 Like

This is what I get:

sudo pacman -Syuv
 
Root      : /
Conf File : /etc/pacman.conf
DB Path   : /var/lib/pacman/
Cache Dirs: /var/cache/pacman/pkg/  
Hook Dirs : /usr/share/libalpm/hooks/  /etc/pacman.d/hooks/  
Lock File : /var/lib/pacman/db.lck
Log File  : /var/log/pacman.log
GPG Dir   : /etc/pacman.d/gnupg/
Targets   : None
:: Synchronizing package databases...
error: failed to synchronize all databases (unexpected error)

The error occured after I replaced some old files with their new .pacnew files. I thought I was careful, but apparentely not careful enough.
Unfortunately I do not remember all the files I replaced and I didn’t save the originals.

That would have been good to know - if you did it in a terminal, the info is still there, in the SHELL history file.

What is the result of this:
grep alpm /etc/group
?

should be:
alpm:x:956:

and perhaps also:
grep alpm /etc/passwd

should be:
alpm:x:956:956:Manjaro Linux Package Management:/:/usr/bin/nologin

These are the only things I can come up with right now.

1 Like

Pacman has a --debug option which might give a clue where it starts to go wrong.

2 Likes

These are the outputs

grep alpm /etc/group
alpm:x:959:

and

grep alpm /etc/passwd

does not give any output at all.

/etc/passwd
was one of the files that had a .pacnew to merge with

That user (alpm) is missing from your system then - I don’t know how to properly add it.
Someone else will know, for sure.

1 Like

Here is the output

sudo pacman -Syu --debug

debug: pacman v7.0.0 - libalpm v15.0.0
debug: config: new section 'options'
debug: config: HoldPkg: pacman
debug: config: HoldPkg: glibc
debug: config: HoldPkg: manjaro-system
debug: config: Architecture: auto
debug: config: arch: x86_64
debug: config: sandboxuser: alpm
debug: config: SigLevel: Required
debug: config: SigLevel: DatabaseOptional
debug: config: LocalFileSigLevel: Optional
debug: config: new section 'core'
debug: config file /etc/pacman.conf, line 72: including /etc/pacman.d/mirrorlist
debug: config: new section 'extra'
debug: config file /etc/pacman.conf, line 75: including /etc/pacman.d/mirrorlist
debug: config: new section 'multilib'
debug: config file /etc/pacman.conf, line 81: including /etc/pacman.d/mirrorlist
debug: config: finished parsing /etc/pacman.conf
debug: setup_libalpm called
debug: option 'logfile' = /var/log/pacman.log
debug: option 'gpgdir' = /etc/pacman.d/gnupg/
debug: option 'hookdir' = /etc/pacman.d/hooks/
debug: option 'cachedir' = /var/cache/pacman/pkg/
debug: registering sync database 'core'
debug: database path for tree core set to /var/lib/pacman/sync/core.db
debug: "/var/lib/pacman/sync/core.db.sig" is not readable: No such file or directory
debug: sig path /var/lib/pacman/sync/core.db.sig could not be opened
debug: got error 43 at _alpm_gpgme_checksig (../lib/libalpm/signing.c: 599) : missing PGP signature
debug: missing optional signature
debug: setting usage of 15 for core repository
debug: adding new server URL to database 'core': http://ftp.free.org/mirrors/repo.manjaro.org/repos/stable/core/x86_64
debug: adding new server URL to database 'core': https://mirrors.nic.cz/manjaro/stable/core/x86_64
debug: adding new server URL to database 'core': https://mirrors.cicku.me/manjaro/stable/core/x86_64
debug: adding new server URL to database 'core': https://ftp.lysator.liu.se/pub/manjaro/stable/core/x86_64
debug: adding new server URL to database 'core': https://manjaro.repo.cure.edu.uy/stable/core/x86_64
debug: registering sync database 'extra'
debug: database path for tree extra set to /var/lib/pacman/sync/extra.db
debug: "/var/lib/pacman/sync/extra.db.sig" is not readable: No such file or directory
debug: sig path /var/lib/pacman/sync/extra.db.sig could not be opened
debug: got error 43 at _alpm_gpgme_checksig (../lib/libalpm/signing.c: 599) : missing PGP signature
debug: missing optional signature
debug: setting usage of 15 for extra repository
debug: adding new server URL to database 'extra': http://ftp.free.org/mirrors/repo.manjaro.org/repos/stable/extra/x86_64
debug: adding new server URL to database 'extra': https://mirrors.nic.cz/manjaro/stable/extra/x86_64
debug: adding new server URL to database 'extra': https://mirrors.cicku.me/manjaro/stable/extra/x86_64
debug: adding new server URL to database 'extra': https://ftp.lysator.liu.se/pub/manjaro/stable/extra/x86_64
debug: adding new server URL to database 'extra': https://manjaro.repo.cure.edu.uy/stable/extra/x86_64
debug: registering sync database 'multilib'
debug: database path for tree multilib set to /var/lib/pacman/sync/multilib.db
debug: "/var/lib/pacman/sync/multilib.db.sig" is not readable: No such file or directory
debug: sig path /var/lib/pacman/sync/multilib.db.sig could not be opened
debug: got error 43 at _alpm_gpgme_checksig (../lib/libalpm/signing.c: 599) : missing PGP signature
debug: missing optional signature
debug: setting usage of 15 for multilib repository
debug: adding new server URL to database 'multilib': http://ftp.free.org/mirrors/repo.manjaro.org/repos/stable/multilib/x86_64
debug: adding new server URL to database 'multilib': https://mirrors.nic.cz/manjaro/stable/multilib/x86_64
debug: adding new server URL to database 'multilib': https://mirrors.cicku.me/manjaro/stable/multilib/x86_64
debug: adding new server URL to database 'multilib': https://ftp.lysator.liu.se/pub/manjaro/stable/multilib/x86_64
debug: adding new server URL to database 'multilib': https://manjaro.repo.cure.edu.uy/stable/multilib/x86_64
debug: option 'sandboxuser' = alpm
:: Synchronizing package databases...
error: failed to synchronize all databases (unexpected error)
debug: unregistering database 'local'
debug: unregistering database 'core'
debug: unregistering database 'extra'
debug: unregistering database 'multilib'

Looks like signatures for each repo are missing. How could this be fixed?
I already tried to update all keys by following these steps:
https://wiki.manjaro.org/index.php/Pacman_troubleshooting#Errors_about_Keys

Yes, first I replaced the original /etc/passwd with it’s .pacnew equivalent.
After realising it was a bad decision I replaced it with the backup file again /etc/passwd-
I thought this would make it all back to normal…

It was a smart move.
But that user (alpm) was not in there - and it not existing is now perhaps the cause of your problem.
That user (not just the group) needs to be added.
I don’t know how exactly to do it. :man_shrugging:
If I knew I’d tell you.

/etc/shadow and /etc/gshadow also needs to reflect it

adduser ... or useradd ... … something like that needs to be run in order to create it

1 Like

This is my output

grep alpm /etc/shadow
alpm:!*:20024::::::
grep alpm /etc/gshadow
alpm:!*::

I will see if I can find the right way to do this:

I am sure you would. Thanks so much for your help. I think we came alot closer to the solution.

If it is only missing from /etc/passwd
(it is present in /etc/shadow and /etc/gshadow and /etc/group …)
then adding this line to /etc/passwd should work™

alpm:x:956:956:Manjaro Linux Package Management:/:/usr/bin/nologin

The numbers need to match the ones in the other files - this is from my own system and the user and group numbers likely are not the same as yours.

Probably re-login or reboot before testing the effect.

1 Like

I added the line, adjusted the numbers. Grep output is now

grep alpm /etc/passwd
alpm:x:959:959:Manjaro Linux Package Management:/:/usr/bin/nologin

The problem is not gone, but it changed. Now I get this error trying to sync:

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

It changed from (unexpected error) to (unable to lock database)

the database file has the wrong permissions
or
just remove the still present lock file:
/var/lib/pacman/db.lck

I’m really just guessing now.