On an Oracle Linux 8, I installed a new package and did not pay attention that dnf used an old Oracle Linux 7 repository. Trying to remove it again, I was getting following error:

Error:
Problem: The operation would result in removing the following protected packages: systemd
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

In this blog I would like to share the solution with you.

So I was just running dnf install, as described here:

[root@SRV ~]# dnf install libzstd
Last metadata expiration check: 0:03:23 ago on Tue 02 Jun 2026 04:18:15 PM CEST.
Package libzstd-1.4.4-1.0.1.el8.x86_64 is already installed.
Dependencies resolved.
=========================================================================================================================================================================================
Package                                     Architecture                               Version                                           Repository                                Size
=========================================================================================================================================================================================
Upgrading:
libzstd                                     x86_64                                     1.5.5-1.el7                                       epel                                     292 k

Transaction Summary
=========================================================================================================================================================================================
Upgrade  1 Package

Total download size: 292 k
Is this ok [y/N]: y
Downloading Packages:
[MIRROR] libzstd-1.5.5-1.el7.x86_64.rpm: Curl error (56): Failure when receiving data from the peer for https://fedora-archive.ip-connect.info/epel/7/x86_64/Packages/l/libzstd-1.5.5-1.el7.x86_64.rpm [Received HTTP code 403 from proxy after CONNECT]
[MIRROR] libzstd-1.5.5-1.el7.x86_64.rpm: Status code: 403 for http://fedora-archive.ip-connect.info/epel/7/x86_64/Packages/l/libzstd-1.5.5-1.el7.x86_64.rpm (IP: 172.16.1.200)
[MIRROR] libzstd-1.5.5-1.el7.x86_64.rpm: Curl error (56): Failure when receiving data from the peer for https://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/epel/7/x86_64/Packages/l/libzstd-1.5.5-1.el7.x86_64.rpm [Received HTTP code 403 from proxy after CONNECT]
[MIRROR] libzstd-1.5.5-1.el7.x86_64.rpm: Status code: 403 for http://ftp-stud.hs-esslingen.de/pub/Mirrors/archive.fedoraproject.org/epel/7/x86_64/Packages/l/libzstd-1.5.5-1.el7.x86_64.rpm (IP: 172.16.1.200)
libzstd-1.5.5-1.el7.x86_64.rpm                                                                                                                           384 kB/s | 292 kB     00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                    306 kB/s | 292 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                 1/1
  Upgrading        : libzstd-1.5.5-1.el7.x86_64                                                                                                                                      1/2
  Running scriptlet: libzstd-1.5.5-1.el7.x86_64                                                                                                                                      1/2
  Cleanup          : libzstd-1.4.4-1.0.1.el8.x86_64                                                                                                                                  2/2
  Running scriptlet: libzstd-1.4.4-1.0.1.el8.x86_64                                                                                                                                  2/2
  Verifying        : libzstd-1.5.5-1.el7.x86_64                                                                                                                                      1/2
  Verifying        : libzstd-1.4.4-1.0.1.el8.x86_64 

Unfortunately, I was too fast and did not realize dnf was using an el7 repo. And more over the command removed the proper el8 package to install the el7 package.

I agree, I should have pay attention and see:

Package libzstd-1.4.4-1.0.1.el8.x86_64 is already installed.

Or package version to be: 1.5.5-1.el7

Anyhow, I realized after having push y.

And trying to remove it, gave following error message:

[root@SRV ~]# dnf remove libzstd-1.5.5-1.el7.x86_64
Error:
Problem: The operation would result in removing the following protected packages: systemd
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

So it seems it is a full mess now. But checking which installed rpm package requires libzstd, I was surprised to see none:

[root@SRV ~]# rpm -q --whatrequires libzstd
no package requires libzstd

The problem was that after a previous upgrade to Oracle linux 8, and as leapp upgrade does not remove custom repo, there was still an el7 customized repo, epel, activated.

[root@SRV ~]# cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=http://download.example/pub/epel/7/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

At that time, I asked one of my colleague having very good linux experience, Joel Cattin, who guided me to the resolution. I would like to take the opportunity here, to thank him again for the great help.

We first tried to cleanup the cache and to upgrade the package, but it did not helped:

[root@SRV yum.repos.d]# dnf clean all
66 files removed

[root@SRV yum.repos.d]# dnf make cache
No such command: make. Please use /usr/bin/dnf --help
It could be a DNF plugin command, try: "dnf install 'dnf-command(make)'"

[root@SRV yum.repos.d]# dnf upgrade libzstd
Oracle Linux 8 EPEL Packages for Development (x86_64)                                                                                                                        10 MB/s | 111 MB     00:10
Oracle Linux 8 EPEL Modular Packages for Development (x86_64)                                                                                                               2.3 MB/s | 332 kB     00:00
Oracle Linux 8 BaseOS Latest (x86_64)                                                                                                                                        10 MB/s | 143 MB     00:13
Oracle Linux 8 Application Stream (x86_64)                                                                                                                                   10 MB/s |  81 MB     00:07
Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)                                                                                                   11 MB/s | 146 MB     00:13
Dependencies resolved.
Nothing to do.
Complete!

[root@SRV yum.repos.d]# rpm -qa | grep -i el7
libzstd-1.5.5-1.el7.x86_64


Still getting the error:

[root@SRV yum.repos.d]# dnf remove libzstd
Error:
 Problem: The operation would result in removing the following protected packages: systemd
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
[root@SRV yum.repos.d]#

And we finally went to the magic command, dnf distro-sync, which will synchronize the installed package with the versions available in the enabled repositories, and most important the repository that should match the version. So in my case an el8 repo.

And this command did the work, removing the el7 package and installing the el8 version package.

[root@SRV ~]# dnf distro-sync libzstd
Last metadata expiration check: 0:23:38 ago on Wed 03 Jun 2026 07:27:26 AM CEST.
Dependencies resolved.
===========================================================================================================================================================================
 Package                             Architecture                       Version                                        Repository                                     Size
===========================================================================================================================================================================
Downgrading:
 libzstd                             x86_64                             1.4.4-1.0.1.el8                                ol8_baseos_latest                             266 k

Transaction Summary
===========================================================================================================================================================================
Downgrade  1 Package

Total download size: 266 k
Is this ok [y/N]: y
Downloading Packages:
libzstd-1.4.4-1.0.1.el8.x86_64.rpm                                                                                                         1.5 MB/s | 266 kB     00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                      1.4 MB/s | 266 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                   1/1
  Downgrading      : libzstd-1.4.4-1.0.1.el8.x86_64                                                                                                                    1/2
  Cleanup          : libzstd-1.5.5-1.el7.x86_64                                                                                                                        2/2
  Running scriptlet: libzstd-1.5.5-1.el7.x86_64                                                                                                                        2/2
  Verifying        : libzstd-1.4.4-1.0.1.el8.x86_64                                                                                                                    1/2
  Verifying        : libzstd-1.5.5-1.el7.x86_64                                                                                                                        2/2

Downgraded:
  libzstd-1.4.4-1.0.1.el8.x86_64

Complete!

And finally, I did not have any remaining el7 package. The version of libzstd package was one from the ol8 distribution.

[root@SRV ~]# rpm -qa | grep -i el7
[root@SRV ~]# rpm -qa | grep -i libzstd
libzstd-1.4.4-1.0.1.el8.x86_64
[root@SRV ~]#

And to avoid problem again, I did what should be done after all leapp upgrade… Removing any el7 repo, in my case the epel el7 repo:

[root@SRV ~]# rpm -qa | grep -i epel
epel-release-7-14.noarch
[root@SRV ~]# dnf remove epel-release-7-14.noarch
Dependencies resolved.
=========================================================================================================================================================================================
 Package                                          Architecture                               Version                                   Repository                                   Size
=========================================================================================================================================================================================
Removing:
 epel-release                                     noarch                                     7-14                                      @System                                      25 k

Transaction Summary
=========================================================================================================================================================================================
Remove  1 Package

Freed space: 25 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                 1/1
  Running scriptlet: epel-release-7-14.noarch                                                                                                                                        1/1
  Erasing          : epel-release-7-14.noarch                                                                                                                                        1/1
  Running scriptlet: epel-release-7-14.noarch                                                                                                                                        1/1
  Verifying        : epel-release-7-14.noarch                                                                                                                                        1/1

Removed:
  epel-release-7-14.noarch

Complete!

I again checked that no other el7 repo was enabled:

[root@SRV ~]# dnf repolist all --enabled
repo id                                                         repo name
ol8_UEKR6                                                       Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)
ol8_appstream                                                   Oracle Linux 8 Application Stream (x86_64)
ol8_baseos_latest                                               Oracle Linux 8 BaseOS Latest (x86_64)
[root@SRV ~]#

I installed the el8 epel repo, as customer was using it:

[root@SRV yum.repos.d]# dnf install oracle-epel-release-el8
Last metadata expiration check: 0:50:57 ago on Tue 02 Jun 2026 04:18:15 PM CEST.
Dependencies resolved.
=========================================================================================================================================================================================
 Package                                              Architecture                        Version                                   Repository                                      Size
=========================================================================================================================================================================================
Installing:
 oracle-epel-release-el8                              x86_64                              1.0-5.el8                                 ol8_baseos_latest                               15 k

Transaction Summary
=========================================================================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 18 k
Is this ok [y/N]: y
Downloading Packages:
oracle-epel-release-el8-1.0-5.el8.x86_64.rpm                                                                                                             136 kB/s |  15 kB     00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                    134 kB/s |  15 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                 1/1
  Installing       : oracle-epel-release-el8-1.0-5.el8.x86_64                                                                                                                        1/1
  Verifying        : oracle-epel-release-el8-1.0-5.el8.x86_64                                                                                                                        1/1

Installed:
  oracle-epel-release-el8-1.0-5.el8.x86_64

Complete!

And checked again the enabled repo to ensure there is only el8 repo with now the epel el8 repo as additional one:

[root@SRV yum.repos.d]# dnf repolist all --enabled
repo id                                                              repo name
ol8_UEKR6                                                            Latest Unbreakable Enterprise Kernel Release 6 for Oracle Linux 8 (x86_64)
ol8_appstream                                                        Oracle Linux 8 Application Stream (x86_64)
ol8_baseos_latest                                                    Oracle Linux 8 BaseOS Latest (x86_64)
ol8_developer_EPEL                                                   Oracle Linux 8 EPEL Packages for Development (x86_64)
ol8_developer_EPEL_modular                                           Oracle Linux 8 EPEL Modular Packages for Development (x86_64)
[root@SRV yum.repos.d]#

And last repo check in the repo files directly:

[root@SRV ~]# ls -ltrh /etc/yum.repos.d/
total 40K
-rw-r--r--. 1 root root  530 Mar 28  2022 oracle-epel-ol8.repo
-rw-r--r--. 1 root root  243 May 23  2024 virt-ol8.repo
-rw-r--r--. 1 root root 1.4K Apr 22  2025 epel-testing.repo
-rw-r--r--. 1 root root 1.8K Apr 22  2025 epel-testing-modular.repo
-rw-r--r--. 1 root root 1.7K Apr 22  2025 epel-modular.repo
-rw-r--r--. 1 root root 4.5K Sep 19  2025 leapp-upgrade-repos-ol8.repo.save
-rw-r--r--. 1 root root 4.1K Jun  2 13:46 oracle-linux-ol8.repo
-rw-r--r--. 1 root root  941 Jun  2 13:46 uek-ol8.repo

[root@SRV ~]# rm -f /etc/yum.repos.d/leapp-upgrade-repos-ol8.repo.save

[root@SRV ~]# grep -i el7 /etc/yum.repos.d/*
[root@SRV ~]# grep -i el8 /etc/yum.repos.d/* | wc -l
6
[root@SRV ~]# grep -i ol8 /etc/yum.repos.d/* | wc -l
50
[root@SRV ~]# grep -i ol7 /etc/yum.repos.d/* | wc -l
0
[root@SRV ~]#