FreeBSD, bootstrapping pkg, “pkg-static: sqlite error while executing INSERT OR ROLLBACK INTO pkg_search”

freebsdpkg

I was trying to install bash on a FreeBSD 10.2 system, see How to Install bash on FreeBSD

But the install failed because pkg was trying to fetch from a too-new repository.

I then tried following the recipe at https://glasz.org/sheeplog/2017/02/freebsd-usrlocalliblibpkgso3-undefined-symbol-utimensat.html, which several sources said was the right thing to do.

However, part of the recipe involved uninstalling pkg and reinstalling it. That resulted in the following:

# pkg install -y pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y

Bootstrapping pkg from 
pkg+http://pkg.FreeBSD.org/FreeBSD:10:amd64/release_2, please 
wait...
Verifying signature with trusted certificate 
pkg.freebsd.org.2013102301... done
pkg-static: warning: database version 34 is newer than libpkg(3) 
version 31, but still compatible
pkg-static: sqlite error while executing INSERT OR ROLLBACK INTO 
pkg_search(id, name, origin) VALUES (?1, ?2 || '-' || ?3, ?4); in 
file pkgdb.c:1542: no such table: pkg_search

And so now I'm stuck. Can anybody tell me how I might recover from this state?

Best Answer

You can try removing everything in /var/db/pkg/ directory, but the proper solution is to upgrade to supported FreeBSD release (10.4 or 11.2)

Related Question