pkgdb.db locked

Mikhail Goriachev mikhailg at
Mon Jun 19 15:08:45 UTC 2006

Lewis McLouth wrote:
> Hello.
> When I run the command pkgdb -Fu, I get the response
> [Rebuilding the pkgdb <format:dbm_hash> in /var/db/pkg ... can't convert
> String into Integer: Cannot update the pkgdb!]
> I think I know where I goofed, so here's the story on my suspected mistake.
> I just upgraded from RELENG_5_4 to RELENG_6, which went fairly smooth. 
> I'm now upgrading my ports but I was foolish today and ran portupgrade
> without first reading /usr/ports/UPDATING.  I think this is the source
> of my problem (as in, running the command.  Of course not reading
> UPDATING is another problem! but I don't need help with that).
> So, I first ran
> portupgrade -arR
> portupgrade did not upgrade linux_base-8 and instead reported that it
> was marked as IGNORE and to use linux_base-fc-4.  So, I ran the commands
> cd /usr/ports/emulators/linux_base-8
> make deinstall
> cd ../linux_base-fc-4
> make install clean
> This it did fine, but when I now try to run pkgdb -Fu, I get the
> following output:
> [Rebuilding the pkgdb <format:dbm_hash> in /var/db/pkg ... can't convert
> String into Integer: Cannot update the pkgdb!]
> I then read /usr/ports/UPDATING, saw that linux_base-8 was dropped and
> replaced by linux_base-fc-4.
> So, I then did the suggested command.
> portupgrade -f -o emulators/linux_base-fc4 linux_base\*
> This produced
> [Rebuilding the pkgdb <format:dbm_hash> in /var/db/pkg ... [Rebuilding
> the pkgdb <format:dbm_hash> in /var/db/pkg ... ** Database file locked.
> Waiting.
> ** Timeout. Lock looks dead. Remove it.
> /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:261:in `origin': can't
> convert String into Integer: Cannot update the pkgdb!] (PkgDB::DBError)
>        from /usr/local/lib/ruby/site_ruby/1.8/pkginfo.rb:178:in `origin'
>        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:977:in `tsort_build'
>        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:971:in `tsort_build'
>        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:993:in `sort_build'
>        from /usr/local/lib/ruby/site_ruby/1.8/pkgdb.rb:997:in `sort_build!'
>        from /usr/local/sbin/portupgrade:705:in `main'
>        from /usr/local/lib/ruby/1.8/optparse.rb:815:in `initialize'
>        from /usr/local/sbin/portupgrade:216:in `main'
>        from /usr/local/sbin/portupgrade:2048
> I've googled for the phrase 'pkgdb "Lock looks dead"' and various
> combinations of the output hoping to learn how to unlock pkgdb.db but
> with no luck.  Plus, I cannot locate pkgdb.dg with
> ls -a /var/db/pkg
> My questions are:  How do I remove the lock on pkgdb?  Where does
> pkgdb.db go when its locked? find does not locate it.  I ran
> find / pkgdb.db | grep pkgdb.db
> find: pkgdb.db: No such file or directory
> Also, if pkgdb.db was deleted, how do I rebuild the pkgdb.db? (pkgdb -f
> does not rebuild pkgdb.db, I just checked)
> The output of uname -a and ls /var/db/pkg are attached.
> Any help would be appreciated.


I'm not an expert, but I'll chuck my 2c in this. I once had a
disagreement with pkgdb myself. The conflict ended up by removing the
contents of:


Before that, I deinstalled all packages though.

After the cleansing session, I reinstalled all ports from scratch. pkgdb
is happy now. The thing is, I only had around 10 packages installed, so
rebuilding them wasn't an issue for me. For sure that was dirty but quick.


Mikhail Goriachev

Telephone: +61 (0)3 62252501
Mobile Phone: +61 (0)4 38255158
E-Mail: mikhailg at

PGP Key ID: 0x4E148A3B
PGP Key Fingerprint: D96B 7C14 79A5 8824 B99D 9562 F50E 2F5D 4E14 8A3B

More information about the freebsd-questions mailing list