DEV Community

Preetham
Preetham

Posted on

Dependency hell in Linux (centos 7)

I needed to update the Kubernetes and docker in three test centOS 7 servers, a master and two slaves, installed using kubeadm. Now, this was my first time using centOS. The server was not maintained for nearly a decade. I checked the status of existing Kubernetes and found that many files were missing. Updating it was also not possible as the required file structure was messed up. It might probably the result of a previously failed installation or upgrade :p .

Hence I decided to uninstall both the docker and Kubernetes and tried to reinstall it and voila, that's when I stumbled into the dependency hell.

I checked the repositories with

yum repolist repo id repo name status Server local 3831 base/7/x86_64 CentOS-7 - Base 10070 azure-cli Azure CLI 76 docker-ce-stable/x86_64 Docker CE Stable - x86_64 79 jenkins Jenkins-stable 106 kubernetes/x86_64 Kubernetes 14+528 spcclient2.4 Spacewalk Client 2.4 27 treasuredata/7/x86_64 TreasureData 15 
Enter fullscreen mode Exit fullscreen mode

In one worker server, I saw the CentOS-7 - Base repository was also missing.
So I tried installing it by

yum install centos-release No packages found 
Enter fullscreen mode Exit fullscreen mode

Now, among my available repositories, none had centos-release.

So I went in and searched for the Centos-release Download for Linux (rpm)

I went into https://pkgs.org/download/centos-release and selected the link to rpm in CentOS x86_64.

I copied the binary package URL under the downloads section, and tried to install it in the machine.

#yum install -y <copied link> yum install -y http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-8.2003.0.el7.centos.x86_64.rpm 
Enter fullscreen mode Exit fullscreen mode

This installed it properly and I verified it using yum repolist.

I also came to know that the extra packages repository was needed and I tried to install it.

yum install epel-release 
Enter fullscreen mode Exit fullscreen mode

I got the same issue - package not found.

I then found a workaround - use official fedora repository

cd /tmp wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm ls *.rpm 
Enter fullscreen mode Exit fullscreen mode

It was installed smoothly and I verified it.

yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repos-tx.psychz.net * epel: d2lzkl7pfhq30w.cloudfront.net * extras: centos-distro.1gservers.com * remi-safe: repo1.dal.innoscale.net * updates: mirror.teklinks.com * webtatic: us-east.repo.webtatic.com repo id repo name status Server local 3831 base/7/x86_64 CentOS-7 - Base 10070 docker-ce-stable/x86_64 Docker CE Stable - x86_64 79 epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13383 extras/7/x86_64 CentOS-7 - Extras 412 kubernetes/x86_64 Kubernetes 14+528 remi-safe Safe Remi's RPM repository for Enterprise Linux 7 - x86_64 3836 spcclient2.4 Spacewalk Client 2.4 27 updates/7/x86_64 CentOS-7 - Updates 900 webtatic/x86_64 Webtatic Repository EL7 - x86_64 725 repolist: 33277 
Enter fullscreen mode Exit fullscreen mode

Now, I tried installing docker and It went smoothly in the machines where I manually installed the base release repository.

But in my master machine, I still faced the dependency issue. It even said that you have installed x.1.23 and the required is x.1.23_noarch.
But when I checked the repolist, it was the same in all 3 machines.

I tried many different approaches. I even manually installed the dependencies in the same way I installed the Centos-release package. That was daunting, as the dependency went in loop, parent package needed 2 child packages and the child packages needed 2,3,4 etc child packages and so on.

After checking, even after

yum update 
Enter fullscreen mode Exit fullscreen mode

the actual centos-release base repository was not updated.

checking the available repos

ls /etc/yum.repos.d CentOS-Base.repo remi-glpi92.repo CentOS-CR.repo remi-glpi93.repo CentOS-Debuginfo.repo remi-glpi94.repo CentOS-Media.repo remi-modular.repo CentOS-Sources.repo remi-php54.repo CentOS-Vault.repo remi-php70.repo CentOS-fasttrack.repo remi-php71.repo CentOS-x86_64-kernel.repo remi-php72.repo docker-ce.repo remi-php73.repo epel-testing.repo remi-php74.repo epel.repo remi-safe.repo jkastner-dnf-plugins-core-epel-7.repo remi.repo kubernetes.repo spcclnt24_7.repo_bkp local.repo vault.centos.org_centos_7.4.1708_extras_x86_64_.repo mesosphere.repo webtatic-archive.repo old webtatic-testing.repo remi-glpi91.repo webtatic.repo 
Enter fullscreen mode Exit fullscreen mode

I checked the contents of CentOS-Base.repo

cat /etc/yum.repos.d/CentOS-Base.repo 
Enter fullscreen mode Exit fullscreen mode

And voila, someone, manually edited this file.

yum clean packages Eliminate any cached packages from the system and hence I ran it.

yum clean 
Enter fullscreen mode Exit fullscreen mode

I manually removed the base repository files in CentOS-Base.repo /etc/yum.repos.d

rm CentOS-Base.repo 
Enter fullscreen mode Exit fullscreen mode

I installed the Centos-release manually in the master machine also once again, and I was able to install the docker and kubeadm.

Finally, the dependency hell was resolved. My lesson here was to

  1. make sure the necessary repositories are added
  2. check the repository file for issue if it still persists, and if it is an error, remove and reinstall it.
  3. check if it solves the issue.

If this solves it, it is great, else, keeeeeep diggin!!!

Top comments (0)