Dnf not working after upgrade to Fedora 41

Upgrading multiple vms to Fedora 41 was not as smooth as I’ve learned to expect.
Customary, I followed the steps from this official guide – Upgrading Fedora Linux Using DNF System Plugin, which invokes dnf system-upgrade.

In all cases, except on few machines, running sudo dnf distro-sync from post-upgrade would retrieve the old (Fedora 40) packages, which was solved by adding --releasever=41 to the command.

In the remaining cases, however, dnf would not run at all. I would get these errors instead:

$ dnf distro-sync --releasever=41
Traceback (most recent call last):
  File "/usr/bin/dnf", line 56, in <module>
    from dnf.cli import main
  File "/usr/lib/python3.12/site-packages/dnf/__init__.py", line 30, in <module>
    import dnf.base
  File "/usr/lib/python3.12/site-packages/dnf/base.py", line 32, in <module>
    from dnf.comps import CompsQuery
  File "/usr/lib/python3.12/site-packages/dnf/comps.py", line 27, in <module>
    from dnf.exceptions import CompsError
  File "/usr/lib/python3.12/site-packages/dnf/exceptions.py", line 22, in <module>
    import dnf.util
  File "/usr/lib/python3.12/site-packages/dnf/util.py", line 29, in <module>
    import dnf.callback
  File "/usr/lib/python3.12/site-packages/dnf/callback.py", line 22, in <module>
    import dnf.yum.rpmtrans
  File "/usr/lib/python3.12/site-packages/dnf/yum/rpmtrans.py", line 26, in <module>
    import rpm
ModuleNotFoundError: No module named 'rpm'

I’m at loss how to deal with this. Hopefully, someone has a solution.
Thanks.

$ uname -a
Linux myvm 6.11.5-300.fc41.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Oct 22 20:11:15 UTC 2024 x86_64 GNU/Linux
$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="41 (Forty One)"
RELEASE_TYPE=stable

Try sudo dnf upgrade --releasever=41
Note that dnf is upgraded from dnf-3 on f40 to dnf5 on f41 and they do operate a little different.

You can verify if dnf was upgraded by running ls -l /usr/bin/dnf If that shows as a symlink to dnf5 then it was upgraded, but if it shows as a symlink to dnf-3 like this

$ ls -l /usr/bin/dnf
lrwxrwxrwx. 1 root root 5 Aug 14 19:00 /usr/bin/dnf -> dnf-3

then it was not upgraded to the f41 version.

Those messages seem to indicate that it is trying to use the old version (which seems broken) and you may need to run it as sudo dnf5 upgrade --releasever=41 or sudo dnf5 distro-sync --releasever=41

1 Like

Your stacktrace contains /usr/lib/python3.12/site-packages/dnf, which should not exist on Fedora 41, only on Fedora 40. (Fedora 41 uses Python 3.13)
Can you please check whether you are really running Fedora 41?

If you are running Fedora 41, how did you upgrade to Fedora 41? I suspect that something went wrong during your upgrade. If you upgraded using dnf system-upgrade, can you please read through or upload the logs from your system upgrade? dnf system-upgrade log should list a single upgrade step and dnf system-upgrade log --number=1 should show/give the last log, which you could pipe to a file for example by executing dnf system-upgrade log --number=1 > /tmp/system-upgrade.log

(Run these commands as root or with sudo)

Thanks Jeff V and Christian Stadelmann.

You’re both correct, my dnf was pointing to the old dnf-3. I followed the steps from the official instructions, as usual here.

Btw, initially, I reported the first issue here:

So, just ran sudo dnf5 upgrade --releasever=41 successfully, but after reboot dnf upgrade --refresh would still retrieve v.40.

So now going with the second option sudo dnf5 distro-sync --releasever=41 and will see how it goes. The good news is that at least I can execute dnf.

I’ll come back and post the log when finished.
Thanks guys!

2 Likes

Unfortunately, both methods yielded the same result – after reboot dnf is still pulling from the old repo (Fedora 40).

sudo dnf5 upgrade --releasever=41
sudo dnf5 distro-sync --releasever=41

I’ve extracted the log, and gently sanitized it, but I don’t see how I can upload it here (it’s like >8k lines). Let me know. Thanks.

You did not use the dnf system-upgrade method that the do.you link to shows?

Well, the dnf system-upgrade was used on my first attempt. Sorry, I don’t really understand your question.

Can you post:
sudo dnf repolist --enabled
sudo dnf check --duplicates

$ sudo dnf repolist --enabled
repo id                      repo name                                                                                                                                                   
fedora                       Fedora 40 - x86_64                                                                                                                                          
fedora-cisco-openh264        Fedora 40 openh264 (From Cisco) - x86_64                                                                                                                    
updates                      Fedora 40 - x86_64 - Updates
$ sudo dnf check --duplicates
<no output>

I’m confused folks, is there a way to upload a log file here?

You never mentioned dnf system-upgrade, only dnf distro-sync and dnf upgrade with --releasever=41 which are both not the correct way to do an offline system upgrade via dnf. They may result in a mixed state.

2 Likes

Not quite – as I’ve mentioned in my second reply, I followed the standard method to upgrade as per official Upgrading Fedora Linux Using DNF System Plugin , which is using dnf system-upgrade

I’ve updated the original post to make it more clear.

Try fpaste logfile or whatever the name of the logfile is.

You can also run sudo dnf5 distro-sync --releasever=41 fedora\* and see if that works without problems. These are the packages that determines the current repository version.

1 Like

fpaste – awesome – learned something new today!

Here’s the output from $ dnf system-upgrade log --number=1, which should include everything starting from initial upgrade using dnf system-upgrade, and followed by subsequent attempts with dnf5 upgrade --releasever=41 and dnf5 distro-sync --releasever=41

dnf system-upgrade log

Thanks Villy Kruse

The log has:

Oct 29 20:45:37 myvm systemd[1]: Finished dnf-system-upgrade-cleanup.service - System Upgrade using DNF failed.

but I have the same message on another system where the upgrade is working fine.

So, I’ve tried dnf5 distro-sync --releasever=41 fedora\* as VK suggested. It worked fine, and seemingly have fixed the problem – after first reboot, dnf upgrade --refresh updated the system using Fedora 41 repos.

However, on the second reboot, repeated dnf upgrade --refresh pointed to Fedora 40 again. This is bizarre.

Any other suggestions folks?

I will just add this – this is not an isolated issue with new release. I’ve performed upgrade on 8 virtual machines in parallel, and they all had the same problem – after upgrade (dnf system-upgrade), uname would show Fedora 41, however dnf would point back to Fedora 40.

The difference on 3 out of 8 machines was that dnf would not work at all (the original post in this topic).

I don’t know which exact file is providing the current version, but it is one of the files provided by one of the fedora-release* packages. Maybe you should run

rpm -Va 'fedora-release*'

to check if that would show anything.

$ rpm -Va 'fedora-release*'
S.5....T.    /usr/lib/os-release
S.5....T.    /usr/lib/fedora-release
.......T.    /usr/lib/issue
.......T.    /usr/lib/issue.net
..5....T.    /usr/lib/rpm/macros.d/macros.dist
missing     /usr/lib/swidtag/fedoraproject.org/org.fedoraproject.Fedora-40.swidtag
..5....T.    /usr/lib/system-release-cpe
S.5....T.    /usr/lib/systemd/system-preset/85-display-manager.preset
S.5....T.    /usr/lib/systemd/system-preset/90-default.preset
.......T.    /usr/lib/systemd/system-preset/99-default-disable.preset
.......T.    /usr/lib/systemd/user-preset/90-default-user.preset
.......T.    /usr/lib/systemd/user-preset/99-default-disable.preset
..5....T.  l /usr/share/licenses/fedora-release-common/Fedora-Legal-README.txt
.......T.  l /usr/share/licenses/fedora-release-common/LICENSE

Any comments on these messages?

Oct 29 20:45:37 myvm systemd[1]: dnf-system-upgrade.service: Main process exited, code=killed, status=15/TERM
Oct 29 20:45:37 myvm systemd[1]: dnf-system-upgrade.service: Failed with result 'signal'.
Oct 29 20:45:37 myvm systemd[1]: Stopped dnf-system-upgrade.service - System Upgrade using DNF.
Oct 29 20:45:37 myvm systemd[1]: dnf-system-upgrade.service: Triggering OnFailure= dependencies.