Saturday, November 9, 2013

Yum Error: cannot open Packages database

Sometimes it may happen that an error like below is popping out at your CentOS linux box. I don't know why it caused, but know how to resolve this.

Loading "fastestmirror" plugin
error: no dbpath has been set
error: cannot open Packages database in /%{_dbpath}
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in ?
  File "/usr/share/yum-cli/", line 85, in main
  File "/usr/share/yum-cli/", line 163, in getOptionsConfig
  File "/usr/lib/python2.4/site-packages/yum/", line 164, in _getConfig
    self._conf = config.readMainConfig(startupconf)
  File "/usr/lib/python2.4/site-packages/yum/", line 685, in readMainConfig
    yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
  File "/usr/lib/python2.4/site-packages/yum/", line 755, in _getsysver
    idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed

Here is the solution that worked for my case:

[root~]# rm /dev/urandom
[root~]# mknod -m 644 /dev/urandom c 1 9
[root~]# yum clean all

Let me know if you know any other ways to handle this situation. I'd love to learn that case.

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...