It looks as if your /var/lib/pacman/local has been deleted or corrupted somehow.
Signs that pacman needs a local database restoration:
pacman -Qgives absolutely no output, andpacman -Syuerroneously reports that the system is up to date.- When trying to install a package using
pacman -S package, and it outputs a list of already satisfied dependencies.
https://wiki.archlinux.org/title/Pacman/Restore_local_database