2024-03-09 04:09:23 +01:00
# When dnf fails.
## Top
Questions to [David Rotermund ](mailto:davrot@uni-bremen.de )
Let us assume the dnf update inbetween. You lost the remote connection to the computer where the update was running or systemd oom killed the dnf task.
2024-03-09 04:15:46 +01:00
Concerning systemd-oomd, you turn it off via:
```shell
systemctl disable --now systemd-oomd
```
2024-03-09 04:09:23 +01:00
Now you are stuck in dnf limbo. How to get out of it with less effort as possible?
2024-03-09 04:42:05 +01:00
## Try 0
2024-03-09 04:13:49 +01:00
If you can do this without an error then you are on a good way:
```shell
dnf -y remove --duplicates
```
2024-03-09 04:09:23 +01:00
2024-03-09 04:42:05 +01:00
## Try 1
2024-03-09 04:09:23 +01:00
2024-03-09 04:13:49 +01:00
Well, if try 0 resulted in conflicts, we can try to solve them semi-autotamic:
2024-03-09 04:09:23 +01:00
```shell
dnf -y remove --duplicates 2> error.log
cat error.log | awk -F 'from install of|conflicts with file from package' '{print $2}' | sort -u | awk 'NF' | sed s/"^ "/"dnf -y reinstall "/g | sh
2024-03-09 04:13:49 +01:00
dnf -y remove --duplicates 2> error.log
2024-03-09 04:09:23 +01:00
```
2024-03-09 04:42:05 +01:00
## Try 2
2024-03-09 04:09:23 +01:00
2024-03-09 04:13:49 +01:00
We end up here if errors after try 1 still remained:
2024-03-09 04:09:23 +01:00
```shell
cat error.log | awk -F 'from install of|conflicts with file from package' '{print $2}' | sort -u | awk 'NF'
```
2024-03-09 04:28:30 +01:00
Now we need to deal with the remaining problem manually. This package is still broken:
```shell
darktable-4.4.2-1.fc37.x86_64
```
This does not work:
```shell
[root ~]# dnf -y reinstall darktable-4.4.2-1.fc37.x86_64
Last metadata expiration check: 0:03:59 ago on Sat 09 Mar 2024 04:17:07 AM CET.
Package darktable available, but not installed.
No match for argument: darktable-4.4.2-1.fc37.x86_64
Error: No packages marked for reinstall.
```
2024-03-09 04:35:27 +01:00
Okay, maybe we need to delete the old package manually:
```shell
cat error.log | awk -F 'conflicts with file from package' '{print $2}' | sort -u | awk 'NF'
```
The problem lies with:
```shell
darktable-tools-noise-4.0.1-2.fc37.x86_64
```
We will remove it carefully(!!!). Don't use -y and check the list if something important is on the to-be-deleted list:
```shell
dnf remove --noautoremove darktable-tools-noise-4.0.1-2.fc37.x86_64
```
Now we should be able to do this:
```shell
dnf -y remove --duplicates
```
2024-03-09 04:42:05 +01:00
## Finalize
2024-03-09 04:35:27 +01:00
2024-03-09 04:42:05 +01:00
Now we can finalize the repair with:
```shell
2024-03-09 04:46:24 +01:00
dnf -y update --best --allowerasing --skip-broken
2024-03-09 04:42:05 +01:00
```
or
```shell
2024-03-09 04:46:24 +01:00
dnf -y --enablerepo=* update --best --allowerasing --skip-broken
2024-03-09 04:42:05 +01:00
```
Depending on if you want to include other non-default repos from your repo-list.
2024-03-09 04:42:27 +01:00
## Protected packages
2024-03-09 04:42:05 +01:00
If you get complaints about protected system packages, you can disable this protection by:
```shell
mv /etc/dnf/protected.d /etc/dnf/protected.d_xxx
```
However, you should restore the protection later:
```shell
mv /etc/dnf/protected.d_xxx /etc/dnf/protected.d
```