Fix a local or file:// repository after the pacman 7.0.0 upgrade
Symptom
After the pacman 7.0.0 upgrade, a local or file:// repository stops working: pacman cannot read the packages it could read yesterday, with permission-denied style retrieval failures against your own repo directory.
Cause
pacman 7.0.0 introduced DownloadUser = alpm, downloading as an unprivileged user. That user has no access to a local repo directory owned solely by root or by your user with restrictive permissions. Announced as a required manual intervention on archlinux.org.
Fix
Grant the alpm group read access to the repo and make sure directories are traversable:
sudo chown :alpm -R /path/to/local/repo
sudo chmod -R a+rX /path/to/local/repo
sudo pacman -Syu
Also merge the pacman.conf.pacnew that shipped with pacman 7 so you pick up the new defaults:
sudo pacman -S --needed pacman-contrib
sudo DIFFPROG=nvim -E pacdiff
If you must, you can disable the feature by commenting DownloadUser out in /etc/pacman.conf, but fixing permissions is the correct fix.
Verify
sudo pacman -Sy syncs the local repo database and sudo pacman -S <pkg-from-local-repo> installs it. namei -l /path/to/local/repo/repo.db shows the alpm group can traverse every component.