Trouble with yum on RHEL, CentOS and Fedora

I ran into a trouble while updating my Red Hat Enterprise Linux Server release 5.8 (Tikanga). I could not use yum any more:

[root@ohs mnt] yum update
el5_latest                                                                                    | 1.4 kB     00:00
el5_latest/primary                                                                            |  18 MB     00:02
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 _getTsInfo
    pkgSack = self.pkgSack
  File "/usr/lib/python2.4/site-packages/yum/", line 662, in 
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.4/site-packages/yum/", line 502, in _getSacks
  File "/usr/lib/python2.4/site-packages/yum/", line 260, in populateSack
    sack.populate(repo, mdtype, callback, cacheonly)
  File "/usr/lib/python2.4/site-packages/yum/", line 190, in populate
    dobj = repo_cache_function(xml, csum)
  File "/usr/lib64/python2.4/site-packages/", line 42, in getPrimary
TypeError: Parsing primary.xml error: Start tag expected, '<' not found

There are several reasons for this problem.

  1. Check if you are behind a firewall, blocking connection to mirror.
  2. Update libxml2.
  3. Try disabling repos in /etc/yum.repos.d - some of them may cause the problem.
  4. This worked for me. Try executing
    export LD_LIBRARY_PATH=/usr/lib64:/usr/local/lib
    then run
    yum clean all
    and test your yum.

If it’s okay - add this export statement to your .bash_profile