ArchLinux 出现错误 invalid or corrupted package (PGP signature) 的解决方法

升级系统时,有时会出现这个错误信息:

error: vim: signature from "Levente Polyak (anthraxx) <levente@leventepolyak.net>" is unknown trust
:: File /var/cache/pacman/pkg/vim-8.2.0100-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.

可以尝试以下步骤:

  1. 更新 archlinux-keyring
1
pacman -Sy archlinux-keyring
  1. 更新所有密钥
1
pacman-key --refresh-keys

pacman-key 相关命令

  1. 确保正确初始化密匙环
1
pacman-key --init
  1. /usr/share/pacman/keyring 中重新加载默认密钥
1
pacman-key --populate