pkg icon indicating copy to clipboard operation
pkg copied to clipboard

pkg upgrade -f fails with sqlite error

Open inferiorhumanorgans opened this issue 9 years ago • 4 comments

On an upgrade from 9.3 to 10.3:

# pkg upgrade -f
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Checking for upgrades (1338 candidates):  36%

postfix-2.11.1_4,1 is locked and may not be modified
Checking for upgrades (1338 candidates):  63%
libfreehand00 has no direct installation candidates, change it to libfreehand? [Y/n]: 
Checking for upgrades (1338 candidates):  64%
libe-book00 has no direct installation candidates, change it to libe-book? [Y/n]: 
Checking for upgrades (1338 candidates):  67%
libabw00 has no direct installation candidates, change it to libabw? [Y/n]: 
Checking for upgrades (1338 candidates):  97%
automake14 has no direct installation candidates, change it to automake? [Y/n]: 
Checking for upgrades (1338 candidates): 100%
Processing candidates (1338 candidates): 100%
pkg: sqlite error while executing UPDATE packages SET name=?1  WHERE name=?2; in file pkg_jobs.c:1708: UNIQUE constraint failed: packages.name
pkg: sqlite error while executing UPDATE packages SET name=?1  WHERE name=?2; in file pkg_jobs.c:1708: UNIQUE constraint failed: packages.name
pkg: sqlite error while executing UPDATE packages SET name=?1  WHERE name=?2; in file pkg_jobs.c:1708: UNIQUE constraint failed: packages.name
pkg: sqlite error while executing UPDATE packages SET name=?1  WHERE name=?2; in file pkg_jobs.c:1708: UNIQUE constraint failed: packages.name
Checking integrity...Assertion failed: (strcmp(uid, p->uid) != 0), function pkg_conflicts_check_local_path, file pkg_jobs_conflicts.c, line 387.
Child process pid=77834 terminated abnormally: Abort trap
# pkg --version
1.7.2
# uname -v
FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 02:10:02 UTC 2016     [email protected]:/usr/obj/usr/src/sys/GENERIC 
# sqlite3 /var/db/pkg/local.sqlite "SELECT name, count FROM (SELECT name, count(name) AS count FROM packages GROUP BY name) WHERE count > 1"
# 

inferiorhumanorgans avatar Apr 13 '16 06:04 inferiorhumanorgans

Answer 'n' to all the question should be the workaround (don't worry it should be safe) When we cannot rename because we already have a package with the same name we should have an automatic fallback instead of showing the ugly sql error to the users. I will fix that

bapt avatar Apr 13 '16 07:04 bapt

Yeah I just re-ran pkg upgrade (without -f) and everything seemed to upgrade in an OK manner.

inferiorhumanorgans avatar Apr 14 '16 03:04 inferiorhumanorgans

Just encountered this today while doing a pkg upgrade -f after upgrading to 11.1-RELEASE. Thanks for the workaround.

phyber avatar Jul 27 '17 10:07 phyber

Encountered this today (with 1.16.3) after running pkg upgrade -f upgrading 11.4 to 12.2, cause was gcc6. Removed it and the upgrade succeeded.

jamesoff avatar Jul 17 '21 12:07 jamesoff