It failed because it tried to open .anydbm files in 'rw' mode. If it can't open in 'rw' mode, it should open with 'r' mode.
What version of portage? Is your user in the portage group? What are the modes and owners on the cache?
Cant fix it without info on the problem.
Sorry for taking so long portage-2.0.50-r7 my account is in group portage. the mode of *.anydbm is 644 (root/portage) I just notice that if i do emerge -s with root first, then with a normal account, then the problem occur. If i remove all anydbm and emerge -s with normal accounts first, it works fine (owner of *.anydbm is pclouds, not root anymore) here is the error messages: $emerge -s xvnkb Searching... \Traceback (most recent call last): File "/usr/bin/emerge", line 2331, in ? searchinstance.execute(mysearch) File "/usr/bin/emerge", line 545, in execute if not portage.portdb.xmatch("match-visible",package): File "/usr/lib/portage/pym/portage.py", line 4712, in xmatch myval=match_from_list(mydep,self.xmatch("list-visible",None,mydep,mykey)) File "/usr/lib/portage/pym/portage.py", line 4698, in xmatch myval=self.gvisible(self.visible(self.cp_list(mykey))) File "/usr/lib/portage/pym/portage.py", line 4793, in gvisible myaux=db["/"]["porttree"].dbapi.aux_get(mycpv, ["KEYWORDS"]) File "/usr/lib/portage/pym/portage.py", line 4498, in aux_get self.auxdb[cat] = self.auxdbmodule(self.cachedir,cat,auxdbkeys,uid,portage_gid) File "/usr/lib/portage/pym/portage_db_anydbm.py", line 22, in __init__ self.db = anydbm.open(self.filename, "n", 0664) File "/usr/lib/python2.3/anydbm.py", line 83, in open return mod.open(file, flag, mode) File "/usr/lib/python2.3/dbhash.py", line 16, in open return bsddb.hashopen(file, flag, mode) File "/usr/lib/python2.3/bsddb/__init__.py", line 192, in hashopen d.open(file, db.DB_HASH, flags, mode) bsddb._db.DBAccessError: (13, 'Permission denied')
portage-2.0.50-r8 lacks the prevmask=os.umask(0) / os.umask(prevmask) wrapper the later versions have. It's fixed in .51- meanwhile, could pull down a .51 tarball and take a look at the src.
Bug has been fixed and released in stable portages on or before 2.0.51-r2