I broke “dnf” on my (Fedora 40) localhost; here is how I fixed it.

Fedora 40 Logo

Just a quick one here. Yesterday I was messing around inside the /usr dir and broke the dnf package manager on my Fedora Core 40 machine. Below is how I got it back into working order.

```sh
$ sudo rpm --reinstall --verbose --hash https://kojipkgs.fedoraproject.org/packages/python3.12/3.12.2/2.fc39/x86_64/python3-3.12.2-2.fc39.x86_64.rpm

Retrieving https://kojipkgs.fedoraproject.org/packages/python3.12/3.12.2/2.fc39/x86_64/python3-3.12.2-2.fc39.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:python3-3.12.2-2.fc39 ################################# [ 50%]
Cleaning up / removing...
2:python3-3.12.2-2.fc39 ################################# [100%]

$ rpm --query python3

python3-3.12.2-2.fc39.x86_64

$ which dnf

/usr/bin/dnf

$ dnf --version

4.19.0
Installed: dnf-0:4.19.0-1.fc39.noarch at Mon 11 Mar 2024 07:38:12 AM GMT
Built : Fedora Project at Tue 20 Feb 2024 02:19:51 PM GMT
Installed: rpm-0:4.19.1.1-1.fc39.x86_64 at Wed 21 Feb 2024 07:00:46 PM GMT
Built : Fedora Project at Wed 07 Feb 2024 04:05:57 PM GMT
```

Credit where credit is due: https://unix.stackexchange.com/questions/772064/how-do-i-fix-dnf-after-trying-to-remove-the-system-python-installation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.