15

I am using Fedora 25. I'm trying to install gcc on fedora25 using the sudo dnf install gcc command. It is always showing:

Error: Failed to synchronize cache for repo 'updates'

I am also getting the same error when I try to install other packages. What am I doing wrong?

ks1322
  • 33,961
  • 14
  • 109
  • 164
Naveen Kumar
  • 159
  • 1
  • 1
  • 5

9 Answers9

13

I just ran into this as well. Adding the verbose flag showed the $releasever wasn't set in the url. Check this yourself with dnf update -v

Look for these lines in the output:

Cannot download 'https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=x86_64': Cannot prepare internal mirrorlist: file "repomd.xml" was not found in metalink. 
Error: Failed to synchronize cache for repo 'fedora'

I fixed the issue with dnf clean all && dnf update --releasever=25. This overrides the $releasever with the one you supply. After that, I was able to update and install rpms again.

jcope
  • 131
  • 1
  • 7
7

In /etc/dnf/dnf.conf make sure:

zchunk=false

This fixes it with some mirrors, especially Yandex one.

Danila Vershinin
  • 8,725
  • 2
  • 29
  • 35
4

try clean and update before install solved my problem:

dnf clean all

dnf update

dnf install gcc

silly
  • 887
  • 9
  • 9
1

I had a similar problem (with the same error message appearing) when I was trying to do the update while I was traveling to another country. After I was back, it was automatically resolved and I was able to update and do everything as normal again.

You may try to use the answer in the comments on this other question, which suggests using

 yum-deprecated update

Otherwise, this error probably means you need to change your local links to the mirrors, by

dnf --refresh upgrade 

as answered here or manually to a one that works where you are now using something like the instructions in this url: https://www.cyberciti.biz/tips/rhel5-fedora-core-add-new-yum-repository.html

Rema
  • 11
  • 2
  • It might be worth pointing out that for quite some time now with Fedora *yum-deprecated* no longer works. This proved a huge problem to me because dnf logging is terrible; I finally just filtered */var/log/dnf.rpm.log* but anyway *yum-deprecated* no longer works and I have seen this elsewhere too (as in bugzilla). – Pryftan May 07 '19 at 15:55
1

I am Using Fedora 30. After upgrading fedora 29 to 30 I have faced same issue as "failed to synchronize cache for repo updates". I have tried the following and it resolved my problem.

sudo dnf distro-sync

sudo dnf autoremove
Yunnosch
  • 26,130
  • 9
  • 42
  • 54
0

In my case, the proxy server respond content-length:0 for CONNECT method + https. The libcurl of feodra26 closed the connection for content-length:0.

Http instead of https worked. But the package was legacy and moved to archive. The archive is only available for the https site.
UH Mathematics site provided mirror fadora26. I resolved it by using the site with http.

http://pubmirror2.math.uh.edu/fedora-buffet/archive/

Martin Reiche
  • 1,642
  • 1
  • 16
  • 27
ysnrgt
  • 1
0

I tried this and solved my problem.

$sudo dnf repolist

hyorman
  • 11
  • 5
0

This issue happened for me because of some internet censorship/restrictions in my region (Russia). Tried to use -v flag (long hashes are shortened):

error: Downloading successful, but checksum doesn't match.
Calculated: 1968~51f5(sha512) 1968~51f5(sha512)
Expected: 0d18~d874(sha512) 512d~f41e(sha512)
(http://mirror.linux-ia64.org/fedora/linux/updates/30/Modular/x86_64/repodata/repomd.xml).

Then I enabled VPN and retried dnf update command and now everything looks OK.

UPD: people say that this may be caused by fastestmirror=True setting in /etc/dnf/dnf.conf. I don't think that it is my case because here is no such setting in my config file and fastestmirror is set to False by default.

Andrey Semakin
  • 2,032
  • 1
  • 23
  • 50
0

Same happened to me doing the upgrade from 29 to 30. I fixed with following https://fedoramagazine.org/upgrading-fedora-29-to-fedora-30/ and then

dnf distro-sync --allowerasing  --releasever=30

  • Did't found anything related in https://fedoramagazine.org/upgrading-fedora-29-to-fedora-30/. – ks1322 May 14 '19 at 14:02
  • @ks1322 I think Thorsten refers to the upgrade from 29 to 30 and wanted to put the link to make precise how he did that step which led into the problem for others who come here on the same route. And only after the upgrade, he fixed the dnf problem with the command line written down. I take it that his language might mislead a bit, but I guess he isn't a native speaker. – Bernhard Bodenstorfer Feb 21 '20 at 23:22
  • I see. If so, then the answer should be reworded to make it more clear. Anyway it didn't work for me when I tried it, as I remember. – ks1322 Feb 22 '20 at 09:36