pkg: sqlite error while executing sqlite open in file pkgdb.c:1126: unable to open database file

Kevin Oberman rkoberman at
Wed Oct 11 23:15:18 UTC 2017

On Wed, Oct 11, 2017 at 11:15 AM, Jos Chrispijn <bsdports at>

> Dear group,
> Apparently I have an issue when finalizing the ports with portmanager.
> When I run this batch to update my ports:
> portmaster -y --clean-distfiles
> portmaster -y --clean-packages
> portmaster -y --check-depends
> portmaster -a
> At the end or the update (everything goes well) I sometimes get this
> display:
> --- cut ---
> ===>>> Returning to update check of installed ports
> ===>>> Update check of installed ports complete
> pkg: sqlite error while executing sqlite open in file pkgdb.c:1126: unable
> to open database file
> ===>>> Done displaying pkg-message files
> ===>>> The following actions were performed:
> < list with ports updates (successful) >
> --- cut ---
> I checked numerous solutions, but most of them refer to a solution done
> with the pkg command, while I am using portmaster to upgrade.
> Can someone tell me how I can solve this issue without risking my ports
> collection being corrupted by some pkg command?
> Thanks for your help!
> Jos Chrispijn

While you are using portmaster(8), portmaster, in turn, uses pkg and the
pkg database which is sqlite  So the pkg suggestions are likely reasonable.
It looks like the db is missing, seriously damaged, has protections that
keep portmaster from accessing it, or your db is not in the right pkg is
looking for it.

That said, it's not clear exactly where in the process these occurred. If
you had already installed ports, pkg had already accessed the db several
times. If you can't figure out why the db could not be opened, providing a
bit more information might help.  So might a "pkg check -B" which will read
the db many  times. If you can narrow it down, you can also use sqlite(1)
to issue db queries directly if you are familiar with its commands (mostly
SQL, of course).
Kevin Oberman, Part time kid herder and retired Network Engineer
E-mail: rkoberman at
PGP Fingerprint: D03FB98AFA78E3B78C1694B318AB39EF1B055683

More information about the freebsd-ports mailing list