もがもがしいブログ

もがもがしく生きる

CentOS8: Error: Failed to synchronize cache for repo 'AppStream'

Issue

ある日、sudo dnf updateを実行したところ

$ sudo dnf update
CentOS-8.0 - AppStream                                                                                                                                                                                                                          27  B/s |  38  B     00:01
Error: Failed to synchronize cache for repo 'AppStream'

とエラーが出てupdateできず。dnf.logを確認すると

$ sudo less /var/log/dnf.log
...
2020-01-22T00:23:05Z DEBUG Cannot download 'http://mirrorlist.centos.org/?release=8.0&arch=x86_64&repo=AppStream&infra=stock': Cannot prepare internal mirrorlist: No URLs in mirrorlist.
...

http://mirrorlist.centos.org/?release=8.0&arch=x86_64&repo=AppStream へアクセスすると "Invalid release/repo/arch combination" とのこと。

$ python3 -c 'import dnf, pprint; db = dnf.dnf.Base(); pprint.pprint(db.conf.substitutions,width=1)'
{'arch': 'x86_64',
 'basearch': 'x86_64',
 'releasever': '8.0'}

Resolution

どうやらrelease=8.0は存在せずrelease=8でなければならないようで、レポジトリ修正。

$ sudo vi /etc/yum.repos.d/CentOS-AppStream.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
mirrorlist=http://mirrorlist.centos.org/?release=8&arch=$basearch&repo=AppStream&infra=$infra

$ sudo vi /etc/yum.repos.d/CentOS-Base.repo
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
mirrorlist=http://mirrorlist.centos.org/?release=8&arch=$basearch&repo=BaseOS&infra=$infra

その後sudo dnf updateしたら解決しました。repoのmirrorlistをrelease=$releaseverに戻しても動く。

$ python3 -c 'import dnf, pprint; db = dnf.dnf.Base(); pprint.pprint(db.conf.substitutions,width=1)'
{'arch': 'x86_64',
 'basearch': 'x86_64',
 'releasever': '8'}

そもそもどうしてreleaseverが8.0になったのかは謎。。。

Reference

0016456: CentOS 8 Netinstall broken: "Error setting up base repository" - CentOS Bug Tracker