Problem with the pkg datebase

Matthew Seaman matthew at
Mon Feb 9 09:30:08 UTC 2015

On 02/09/15 09:15, Willem Jan Withagen (EcoRacks) wrote:
> Hi,
> Trying to run a 'pkg upgrade -f' which gives me:
> pkg: sqlite error while executing UPDATE packages SET name=?1  WHERE
> name=?2; in file pkg_jobs.c:1576: UNIQUE constraint failed:
> And upgrading is not really possibe.
> How do I fix the database?

The unique key in the pkg DB changed from port origin to port name
relatively recently.  This means you've managed to get two packages with
the same name but different origins installed -- one way it seems fairly
common to do that is when you had the docbook ports installed, but you
haven't been updating them religiously, but there are other ways.


  pkg query -a "%n\t\t%v %o" | sort | less

and try and spot the repeated name. You may also see some packages that
have been arbitrarily renamed to avoid this sort of collision. Deleting
the affected packages (either repeated name or renamed) and reinstalling
should solve the problem.  There aren't any name collisions possible in
the ports anymore, so once you're fully up to date this shouldn't happen



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 949 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the freebsd-ports mailing list