Yum fails after upgrading CentOS 5.2 -> CentOS 5.3

Posted on 2009-04-24
Last Modified: 2013-12-16
After upgrading CentOS 5.2 to CentOS 5.3 via "yum update" on a server, yum no longer works. "yum install package" or "yum update" now results in the following error:

Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/", line 229, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/", line 104, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/", line 343, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
  File "/usr/share/yum-cli/", line 580, in doCommand
    return base.updatePkgs(extcmds)
  File "/usr/share/yum-cli/", line 565, in updatePkgs
  File "/usr/lib/python2.4/site-packages/yum/", line 2481, in update
    updates = self.up.getUpdatesTuples()
  File "/usr/lib/python2.4/site-packages/yum/", line 604, in <lambda>
    up = property(fget=lambda self: self._getUpdates(),
  File "/usr/lib/python2.4/site-packages/yum/", line 495, in _getUpdates
    self._up.rawobsoletes = self.pkgSack.returnObsoletes(newest=True)
  File "/usr/lib/python2.4/site-packages/yum/", line 591, in <lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.4/site-packages/yum/", line 416, in _getSacks
    if self._pkgSack and thisrepo is None:
  File "/usr/lib/python2.4/site-packages/yum/", line 263, in __len__
    ret += len(sack)
ValueError: __len__() should return >= 0

I've tried "yum clean all" but that did not help. The server is a hardware node for hosting OpenVZ VPS accounts. No problems noticed except for this yum problem.
Question by:tomfra
    LVL 43

    Accepted Solution

    I suggest manually downloading the yum package from centos53 and reinstalling
    rpm -e yum --nodeps
    rpm -ivh --force
    next would be all yum plugins - or try disabling them
    yum --noplugins ...

    Author Comment

    OK, this is strange... your solution helped, but it seems the problem was in the yum.conf file. I backed up the old config file and when I used it with the new yum installation, it failed again.

    For some reason, when this line in yum.conf is not commented out, yum gives the mentioned error:

    exclude=kernel* syslinux* ovzkernel*

    I see nothing wrong with this line and it worked just fine before the upgrade (and there is a very good reason to have the exlude line there). When it's there, it doesn't work. When I comment it out, it works OK. The syntax is correct, have just checked "man yum.conf".

    Any ideas?
    LVL 43

    Expert Comment

    No package match, and therefore "ValueError: __len__() should return >= 0" fails - I suppose. You could submit a bug to the yum project.

    Author Comment

    But there *IS* ovzkernel package (from the OpenVZ repo), when I uncomment the exclude line it actually offers me to install it. Really strange.

    Author Comment

    OK, a nasty bug in the most recent version of Yum apparently:

    Does not work (gives the error):

    exclude=kernel* syslinux* ovzkernel*
    exclude=ovzkernel* syslinux* kernel*

    Works OK:

    exclude=kernel* syslinux* ovzkernel

    For some reason there cannot be the wilcard * character for the last package name. And yes, I am editing the file through command line (or mc actually) so the line end character should not be a problem, it's in the correct *nix format and this very same yum.conf file had been working just fine with previous versions of Yum.

    Really a bug I guess. Anyway, since you helped me solve the problem, I will accept your solution. Thanks for the help!
    LVL 2

    Expert Comment

    "yum clean all" helped in my case

    Author Comment

    The "yum clean all" did not help in my situation, I tried it. In my case it was probably indeed a yummy bug...

    Expert Comment

    yum clean all

    fixed mine

    the yum update now works... my yum.conf didn't have any wild cards in it. It looked very clean and trim.
    The odd part for me is that I generally keep all 5 of my servers uptodate -- so what ever this was it hit all at the same time. My last successful update was 5 weeks ago.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
    The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. Once you open the link you will see …
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now