When pkg won’t update

As part of the upgrades handed down to me by the FreeBSD/TrueNAS teams, I ran into a strange issue where `pkg` was trying to install things from a very-end-of-life package repository, regardless of my configured repositories.

# pkg bootstrap -f
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:12:x86:64/latest, please wait...
pkg: Error fetching http://pkg.FreeBSD.org/freebsd:12:x86:64/latest/Latest/pkg.txz: Not Found
A pre-built version of pkg could not be found for your system.
Consider changing PACKAGESITE or installing it from ports: 'ports-mgmt/pkg'.

When I saw version 12 being used, I went over to my /etc/pkg/FreeBSD.conf to find the presence of an elegant ABI, which I commented out to insist on using the correct package repository for my system:

# $FreeBSD$
#
# To disable this repository, instead of modifying or removing this file,
# create a /usr/local/etc/pkg/repos/FreeBSD.conf file:
#
#   mkdir -p /usr/local/etc/pkg/repos
#   echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.conf
#

FreeBSD: {
  # url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly",
  url: "pkg+http://pkg.FreeBSD.org/freebsd:13:x86:64/latest",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
}

Optimistically, I asked pkg to update once again:

# pkg update
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:12:x86:64/latest, please wait...
pkg: Error fetching http://pkg.FreeBSD.org/freebsd:12:x86:64/latest/Latest/pkg.txz: Not Found
A pre-built version of pkg could not be found for your system.
Consider changing PACKAGESITE or installing it from ports: 'ports-mgmt/pkg'.

Same old version. I tried the recommended pkg bootstrap -f:

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:12:x86:64/latest, please wait...
pkg: Error fetching http://pkg.FreeBSD.org/freebsd:12:x86:64/latest/Latest/pkg.txz: Not Found
A pre-built version of pkg could not be found for your system.
Consider changing PACKAGESITE or installing it from ports: 'ports-mgmt/pkg'.

Confused, I began to wonder if there might be another configuration file overriding this /etc/pkg/FreeBSD.conf, and it turns out there was! In /usr/local/etc/pkg/repos, I found another FreeBSD.conf, which needed similar massaging.

Once I had the trusty ${ABI} in place of the hardcoded freebsd:12:x86:64, I was able to update packages and finally install those pesky all-important upgrades.