Yum fails after upgrading CentOS 5.2 -> CentOS 5.3

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/yummain.py", line 229, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 104, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 343, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 580, in doCommand
    return base.updatePkgs(extcmds)
  File "/usr/share/yum-cli/cli.py", line 565, in updatePkgs
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 2481, in update
    updates = self.up.getUpdatesTuples()
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 604, in <lambda>
    up = property(fget=lambda self: self._getUpdates(),
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 495, in _getUpdates
    self._up.rawobsoletes = self.pkgSack.returnObsoletes(newest=True)
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 591, in <lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 416, in _getSacks
    if self._pkgSack and thisrepo is None:
  File "/usr/lib/python2.4/site-packages/yum/packageSack.py", 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.
Who is Participating?
I suggest manually downloading the yum package from centos53 and reinstalling
rpm -e yum --nodeps
rpm -ivh --force http://mirror.facebook.com/centos/5.3/os/i386/CentOS/yum-3.2.19-18.el5.centos.noarch.rpm
next would be all yum plugins - or try disabling them
yum --noplugins ...
tomfraAuthor Commented:
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?
No package match, and therefore "ValueError: __len__() should return >= 0" fails - I suppose. You could submit a bug to the yum project.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

tomfraAuthor Commented:
But there *IS* ovzkernel package (from the OpenVZ repo), when I uncomment the exclude line it actually offers me to install it. Really strange.
tomfraAuthor Commented:
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!
"yum clean all" helped in my case
tomfraAuthor Commented:
The "yum clean all" did not help in my situation, I tried it. In my case it was probably indeed a yummy bug...
Brian Sretired geekCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.