[Howto] solve pkg “error updating repositories”

posted in: computer | 0

problem:

# pkg update
Updating FreeBSD repository catalogue…
pkg: Repository FreeBSD has a wrong packagesite, need to re-create database
pkg: An error occured while fetching package
pkg: An error occured while fetching package
repository FreeBSD has no meta file, using default settings
pkg: An error occured while fetching package
pkg: An error occured while fetching package
pkg: An error occured while fetching package
pkg: An error occured while fetching package
Unable to update repository FreeBSD
Error updating repositories!

possible solution 1:
there could be a problem with the pkg-program. force a reinstall with the command:

pkg bootstrap -f

possible solution 2:
there could be a problem with the connection to the repository-servers, e.g. missing certificates to establish the secure connection.

#download and extract a fresh FreeBSD base-system
cd /tmp
fetch https://download.freebsd.org/releases/amd64/14.2-RELEASE/base.txz
tar -xf base.txz

#compare the following folders (extracted-folder vs. your-system-folder)
/etc/ssl/certs             <-- possibly missing symlinks to certificate-files
/usr/share/certs/trusted   <-- possibly missing certificate-files

#maybe you must rehash your certificates
certctl rehash

copy the missing symlinks and certfiles from the extracted freeBSD base-system to your corresponding system-folders. Afterwards retry pkg-program – now it should work.