Let’s try and fix the fedora-release packages first so that the system at least tries to get packages for the correct Fedora version.
What does
sudo dnf --releasever=40 update fedora-release\*
say?
Also worth trying:
sudo dnf --releasever=40 reinstall fedora-release\*
(which may trick the system into reinstalling the f40 ones and uninstalling the f38 ones).
Yeh, this is because the deps are all messed up at the moment. It needs to remove some f38 packages, but they’re protected and it doesn’t know how to handle it. So we’ll have to do these bits manually.
Obligatory note: if you have a different /home
partition or a recent backup of your user data, it’ll be quicker to fresh install and re-mount the partition/restore from your backup. Fixing the system is possible in theory, but one cannot say how much tinkering it’ll require.