Friday, February 10, 2012

How to fix a broken yum for CentOS

When we type the command yum, we encounter the error such as the one below.

# yum update
Loaded plugins: downloadonly, fastestmirror
Loading mirror speeds from cached hostfile
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 309, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/", line 178, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/", line 345, in doCommands
  File "/usr/lib/python2.4/site-packages/yum/", line 101, in _getTs
  File "/usr/lib/python2.4/site-packages/yum/", line 112, in _getTsIn                                                                             fo
    pkgSack = self.pkgSack
  File "/usr/lib/python2.4/site-packages/yum/", line 661, in 
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.4/site-packages/yum/", line 501, in _getSack                                                                             s
  File "/usr/lib/python2.4/site-packages/yum/", line 232, in populateSac                                                                             k
  File "/usr/lib/python2.4/site-packages/yum/", line 79, in doSetup'postreposetup')
  File "/usr/lib/python2.4/site-packages/yum/", line 179, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/", line 181, in postreposetup_hook
    all_urls = FastestMirror(all_urls).get_mirrorlist()
  File "/usr/lib/yum-plugins/", line 333, in get_mirrorlist
  File "/usr/lib/yum-plugins/", line 376, in _poll_mirrors
  File "/usr/lib64/python2.4/", line 416, in start
    _start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

Possible Solution 1: (which solve my problem immediately). Modify the the following.
# yum clean all
# vim /etc/yum/pluginconf.d/fastestmirror.conf


Possible Solution 2: The good old yum clean all. (Clean everything)
# yum clean all
Loaded plugins: downloadonly, fastestmirror
Cleaning up Everything
Cleaning up list of fastest mirrors

Possible Solution 3: Rebuild the yum database
# yum clean all
# rm -f /var/lib/rpm/__db*
# rpm --rebuilddb
# yum update
Hope this help.


dbostrom said...

Method #1 sorted out a sporadic, annoying problem w/a VPS not being able to perform updates or installs via cpanel or command line.

Thank you!

w said...

i tried export LANG=en_US.UTF8 and yum update again. it worked.

orvice said...

thx for your post,I solve this problem

RunBitchRun! said...

thanks "w" that solved my problem

vishu said...

Check for server is registered with RHN OR server registeration may be having conflict with another registered server, rhn_check give you exact details, if not register using rhn_register, Registering with RHN will resolve the problem.