Yum fails after upgrading CentOS 5.2 -> CentOS 5.3

Posted on 2009-04-24
Medium Priority
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/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.
Question by:tomfra
LVL 43

Accepted Solution

ravenpl earned 2000 total points
ID: 24231029
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 ...

Author Comment

ID: 24231065
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

ID: 24231132
No package match, and therefore "ValueError: __len__() should return >= 0" fails - I suppose. You could submit a bug to the yum project.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 24231158
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

ID: 24231232
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!

Expert Comment

ID: 24306241
"yum clean all" helped in my case

Author Comment

ID: 24306269
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

ID: 24442106
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Fine Tune your automatic Updates for Ubuntu / Debian
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

621 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