如何解决apt更新时出现的NO_PUBKEY E88979FB9B30ACF2公钥缺失错误?
看起来你在更新Dart官方仓库时碰到了公钥验证失败的问题,这是因为系统还没导入Dart仓库的官方验证密钥,apt没法确认仓库包的安全性,所以拒绝完成更新。别慌,按下面几步操作就能搞定:
步骤1:导入缺失的公钥
现在更推荐用密钥环文件的方式(替代已弃用的apt-key工具),执行以下命令:
# 从密钥服务器获取目标公钥 gpg --keyserver keyserver.ubuntu.com --recv-keys E88979FB9B30ACF2 # 将公钥导出到系统可信密钥目录 gpg --export E88979FB9B30ACF2 | sudo tee /usr/share/keyrings/dart.gpg > /dev/null
步骤2:确保仓库源配置关联密钥环
检查你的Dart仓库配置文件(一般在/etc/apt/sources.list.d/dart.list),确保内容包含signed-by参数指向刚才生成的密钥文件:
deb [signed-by=/usr/share/keyrings/dart.gpg] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main
如果原来的配置没有这个参数,直接编辑文件补上就行。
步骤3:重新执行更新操作
完成上面的设置后,再运行更新命令:
sudo apt update
要是你习惯用传统方式(虽然官方已不推荐),也可以直接执行:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E88979FB9B30ACF2 sudo apt update
这样就能解决公钥缺失的问题,正常更新Dart仓库了。
你遇到的完整错误信息如下:
Err:26 https://storage.googleapis.com/download.dartlang.org/linux/debian stable Release.gpg
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E88979FB9B30ACF2W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://storage.googleapis.com/download.dartlang.org/linux/debian stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E88979FB9B30ACF2
W: Failed to fetch https://storage.googleapis.com/download.dartlang.org/linux/debian/dists/stable/Release.gpg The following signatures couldn't be verified because the public key is not available: NO_PUBKEY E88979FB9B30ACF2
W: Some index files failed to download. They have been ignored, or old ones used instead.
备注:内容来源于stack exchange,提问作者R A

