While I was performing an upgrade of Fedora 41 to 42 on my laptop, I noticed there was package installed since Fedora 38. This package, zfs-dkms-2.2.0-1.fc38.noarch, needed to be removed as it blocked this Fedora 42 upgrade.

TL;DR - The solution is to use --noscripts option with rpm command. If you want to see how the zfs-dkms package removed, follow along.

Here’s the info about the package:

root@benjo:/etc/yum.repos.d# dnf info zfs-dkms
Updating and loading repositories:
Repositories loaded.
Installed packages
Name            : zfs-dkms
Epoch           : 0
Version         : 2.2.0
Release         : 1.fc38
Architecture    : noarch
Installed size  : 56.9 MiB
Source          : zfs-dkms-2.2.0-1.fc38.src.rpm
From repository : zfs
Summary         : Kernel module(s) (dkms)
URL             : https://github.com/openzfs/zfs
License         : CDDL
Description     : This package contains the dkms ZFS kernel modules.
Vendor          : <NULL>

Available packages
Name           : zfs-dkms
Epoch          : 0
Version        : 2.3.2
Release        : 1.fc41
Architecture   : noarch
Download size  : 31.0 MiB
Installed size : 58.6 MiB
Source         : zfs-dkms-2.3.2-1.fc41.src.rpm
Repository     : zfs
Summary        : Kernel module(s) (dkms)
URL            : https://github.com/openzfs/zfs
License        : CDDL
Description    : This package contains the dkms ZFS kernel modules.
Vendor

Let’s try to remove it normally:

root@benjo:/etc/yum.repos.d# dnf remove zfs-dkms
Package                                           Arch         Version                                           Repository                      Size
Removing:
 zfs-dkms                                         noarch       2.2.0-1.fc38                                      zfs                         56.9 MiB

Transaction Summary:
 Removing:           1 package

After this operation, 57 MiB will be freed (install 0 B, remove 57 MiB).
Is this ok [y/N]: y
Running transaction
[1/2] Prepare transaction                                                                                    100% |   0.0   B/s |   1.0   B |  00m01s
>>> Running pre-uninstall scriptlet: zfs-dkms-0:2.2.0-1.fc38.noarch
>>> Error in pre-uninstall scriptlet: zfs-dkms-0:2.2.0-1.fc38.noarch
>>> Scriptlet output:
>>>
>>> Error! The module/version combo: zfs/2.2.0 is not located in the DKMS tree.
>>>
>>> [RPM] %preun(zfs-dkms-2.2.0-1.fc38.noarch) scriptlet failed, exit status 3
Transaction failed: Rpm transaction failed.

It didn’t work. Some folks online suggested to pass --force option dnf, however the DNF on Fedora 41 no longer has that flag.

root@benjo:/etc/yum.repos.d# dnf remove --force zfs-dkms
Unknown argument "--force" for command "remove". Add "--help" for more information about the arguments.

Fortunately, I found the solution from [1], suggesting to use the --noscripts option when calling erase (-e or --erase) with the rpm command. So I tried that.

root@benjo:~# rpm --erase --noscripts zfs-dkms-2.2.0-1.fc38.noarch

No messages, which generally means good news in Linux. Let’s confirm that the package zfs-dkms-2.2.0-1.fc38.noarch is gone.

root@benjo:~# rpm -ql zfs-dkms-2.2.0-1.fc38.noarch
package zfs-dkms-2.2.0-1.fc38.noarch is not installed

That’s it. This is the first time I encountered this corrupted RPM package problem.

Reference: