pkg update error

Hi all,

I'm getting the following error on my FreeBSD 12.1-RELEASE-p2:

Code:
# pkg update
Updating FreeBSD_latest repository catalogue...
pkg: repository meta has wrong version 2
pkg: Repository FreeBSD_latest load error: meta cannot be loaded No error: 0
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg: repository meta has wrong version 2
repository FreeBSD_latest has no meta file, using default settings
Fetching packagesite.txz: 100%    6 MiB   1.1MB/s    00:06
pkg: repository meta has wrong version 2
pkg: Repository FreeBSD_latest load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD_latest
Unable to update repository FreeBSD_latest
Error updating repositories!

This is my pkg config:

Code:
# pkg -vv
Version                 : 1.11.1
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
INDEXDIR = "";
INDEXFILE = "INDEX-12";
HANDLE_RC_SCRIPTS = false;
DEFAULT_ALWAYS_YES = false;
ASSUME_ALWAYS_YES = false;
REPOS_DIR [
    "/etc/pkg/",
    "/usr/local/etc/pkg/repos/",
]
PLIST_KEYWORDS_DIR = "";
SYSLOG = true;
ABI = "FreeBSD:12:amd64";
ALTABI = "freebsd:12:x86:64";
DEVELOPER_MODE = false;
VULNXML_SITE = "http://vuxml.freebsd.org/freebsd/vuln.xml.bz2";
FETCH_RETRY = 3;
PKG_PLUGINS_DIR = "/usr/local/lib/pkg/";
PKG_ENABLE_PLUGINS = true;
PLUGINS [
]
DEBUG_SCRIPTS = false;
PLUGINS_CONF_DIR = "/usr/local/etc/pkg/";
PERMISSIVE = false;
REPO_AUTOUPDATE = true;
NAMESERVER = "";
HTTP_USER_AGENT = "pkg/1.11.1";
EVENT_PIPE = "";
FETCH_TIMEOUT = 30;
UNSET_TIMESTAMP = false;
SSH_RESTRICT_DIR = "";
PKG_ENV {
}
PKG_SSH_ARGS = "";
DEBUG_LEVEL = 0;
ALIAS {
    all-depends = "query %dn-%dv";
    annotations = "info -A";
    build-depends = "info -qd";
    cinfo = "info -Cx";
    comment = "query -i \"%c\"";
    csearch = "search -Cx";
    desc = "query -i \"%e\"";
    download = "fetch";
    iinfo = "info -ix";
    isearch = "search -ix";
    prime-list = "query -e '%a = 0' '%n'";
    prime-origins = "query -e '%a = 0' '%o'";
    leaf = "query -e '%#r == 0' '%n-%v'";
    list = "info -ql";
    noauto = "query -e '%a == 0' '%n-%v'";
    options = "query -i \"%n - %Ok: %Ov\"";
    origin = "info -qo";
    provided-depends = "info -qb";
    rall-depends = "rquery %dn-%dv";
    raw = "info -R";
    rcomment = "rquery -i \"%c\"";
    rdesc = "rquery -i \"%e\"";
    required-depends = "info -qr";
    roptions = "rquery -i \"%n - %Ok: %Ov\"";
    shared-depends = "info -qB";
    show = "info -f -k";
    size = "info -sq";
}
CUDF_SOLVER = "";
SAT_SOLVER = "";
RUN_SCRIPTS = true;
CASE_SENSITIVE_MATCH = false;
LOCK_WAIT = 1;
LOCK_RETRIES = 5;
SQLITE_PROFILE = false;
WORKERS_COUNT = 0;
READ_LOCK = false;
PLIST_ACCEPT_DIRECTORIES = false;
IP_VERSION = 0;
AUTOMERGE = true;
VERSION_SOURCE = "";
CONSERVATIVE_UPGRADE = true;
PKG_CREATE_VERBOSE = false;
AUTOCLEAN = false;
DOT_FILE = "";
REPOSITORIES {
}
VALID_URL_SCHEME [
    "pkg+http",
    "pkg+https",
    "https",
    "http",
    "file",
    "ssh",
    "ftp",
    "ftps",
    "pkg+ssh",
    "pkg+ftp",
    "pkg+ftps",
]
ALLOW_BASE_SHLIBS = false;
WARN_SIZE_LIMIT = 1048576;
METALOG = "";
OSVERSION = 1201000;
IGNORE_OSVERSION = false;


Repositories:
  FreeBSD_latest: {
    url             : "pkg+http://pkg.FreeBSD.org/FreeBSD:12:amd64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }

Any thoughts on what might cause the issue?

Thanks!
 
This is my /usr/local/etc/pkg/repos/FreeBSD.conf:

Code:
FreeBSD: { enabled: no }
FreeBSD_latest: {
   url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
   mirror_type: "srv",
   signature_type: "fingerprints",
   fingerprints: "/usr/share/keys/pkg",
   enabled: yes
}

I would add that I've had the same setup for quite some time and it only recently broke.

Removing the pkg+http scheme results in a deprecation warning.

Even a bare-minimum .conf like so:
Code:
FreeBSD_latest: {
   url: "http://pkg.FreeBSD.org/${ABI}/latest",
}

Results in:
Code:
# pkg update
Updating FreeBSD repository catalogue...
pkg: repository meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Warning: use of http:// URL scheme with SRV records is deprecated: switch to pkg+http://
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg: repository meta has wrong version 2
repository FreeBSD has no meta file, using default settings
Warning: use of http:// URL scheme with SRV records is deprecated: switch to pkg+http://
Fetching packagesite.txz: 100%    6 MiB 461.8kB/s    00:14
pkg: repository meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!


At any rate, I don't think the problem is with the mirror or the connection, but rather with my local database.
 
Code:
# pkg-static install -f pkg
Updating FreeBSD repository catalogue...
pkg-static: repository meta has wrong version 2
pkg-static: Repository FreeBSD load error: meta cannot be loaded No error: 0
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg-static: repository meta has wrong version 2
repository FreeBSD has no meta file, using default settings
Fetching packagesite.txz: 100%    6 MiB   1.1MB/s    00:06
pkg-static: repository meta has wrong version 2
pkg-static: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!

Looks like there is something wrong with the DB.
I remember reading that automatic backups of the DB are being performed, perhaps it's worth investigating that?
 
I remember reading that automatic backups of the DB are being performed, perhaps it's worth investigating that?
I don't think your local registration database is at fault, it only complains about the meta data and SQL from the locally cached remote repositories. Try removing /var/db/pkg/FreeBSD.meta, /var/db/pkg/FreeBSD_latest.meta, /var/db/pkg/repo-FreeBSD.sqlite and /var/db/pkg/repo-FreeBSD_latest.sqlite. Then running pkg update again.

Do NOT remove /var/db/pkg/local.sqlite (it contains the registrations for your currently installed packages). In case you still want to checkout the backups, they're in /var/backups/.
 
Thanks for your suggestions.

Unfortunately it sill gives the same "wrong version 2" error as before:
Code:
# rm /var/db/pkg/FreeBSD.meta
# rm /var/db/pkg/FreeBSD_latest.meta
# rm /var/db/pkg/repo-FreeBSD.sqlite
# rm /var/db/pkg/
local.sqlite  vuln.xml
# pkg update
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg: repository meta has wrong version 2
repository FreeBSD has no meta file, using default settings
Fetching packagesite.txz: 100%    6 MiB   1.1MB/s    00:06
pkg: repository meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!
 
Try updating ports-mgmt/pkg from the ports tree using ports-mgmt/portmaster.
If you haven't fetched the ports tree yet, just do the following:

Code:
# portsnap fetch
# portsnap extract

Once the process is over, assuming you have ports-mgmt/portmaster installed already, run:
Code:
# portmaster pkg

At the end, you should see pkg version 1.13.2 installed (at the time of writing this post)

After I did the above, I got this:
Code:
# pkg upgrade -F
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (3 candidates): 100%
Processing candidates (3 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.
 
I have the same problem. The two portsnap commands worked, but I'm blocked on the "portmaster pkg" step as it is not installed, and "pkg install portmaster" also produces a "wrong version 2" error. Any ideas?
 
If you are using ports (your mention of portsnap...), what happens if you try to build pkg from ports manually?
like this:
Code:
cd /usr/ports/ports-mgmt/pkg
make install clean
cd
 
Thanks for your replies. I can see how that likely would have worked.

Yesterday I continued playing with it and decided to upgrade since I was running an unsupported release (11.0). At some point in the process of moving to 12.1 I wound up with a new enough version of pkg that I was able to overcome the issue using the technique above. And now my server is up to date. :)

The upgrade went smoothly with no disruption to my local configurations - kudos to the FreeBSD team!
 
I've been running into this with 12.0-RELEASE to 12.1-RELEASE and freebsd-update

After a lot of frustration, I've had some success with (using the repo of your architecture and quarterly/latest choice)

Code:
fetch https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/pkg-1.14.2.txz
sudo pkg add -f pkg-1.14.2.txz

pkg-add(8) suggests that

Code:
sudo pkg add -f https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/pkg-1.14.2.txz
would work as a one-liner, though I have not now tried it successfully.
 
Last edited:
I got into this error after updating from 12.0-RELEASE to 12.1-RELEASE.
The solution that worked for me was to forcibly remove pkg

Code:
root@server:/var/db/pkg # pkg update -f
Updating FreeBSD repository catalogue...
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
repository FreeBSD has no meta file, using default settings
Fetching packagesite.txz: 100%    6 MiB  70.9kB/s    01:31
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!
root@server:/var/db/pkg # pkg add -f https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/pkg-1.14.2.txz
Certificate verification failed for /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
34374852608:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:/usr/src/crypto/openssl/ssl/statem/statem_clnt.c:1915:
Certificate verification failed for /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
34374852608:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:/usr/src/crypto/openssl/ssl/statem/statem_clnt.c:1915:
Certificate verification failed for /C=US/O=Let's


root@server:/var/db/pkg # pkg delete -f pkg
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
    pkg-1.10.5_5

Number of packages to be removed: 1

The operation will free 13 MiB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling pkg-1.10.5_5...
[1/1] Deleting files for pkg-1.10.5_5: 100%
root@server:/var/db/pkg # pkg update -f 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:12:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.13.2...
Extracting pkg-1.13.2: 100%
Usage: pkg update [-fq] [-r reponame]

For more information, see 'pkg help update'.
root@server:/var/db/pkg # pkg update
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    163 B   0.2kB/s    00:01
Fetching packagesite.txz: 100%    6 MiB 280.4kB/s    00:23
Processing entries: 100%
FreeBSD repository update completed. 31492 packages processed.
All repositories are up to date.
root@server:/var/db/pkg # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Updating database digests format: 100%
Checking for upgrades (19 candidates): 100%
Processing candidates (19 candidates): 100%
The following 19 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    python37: 3.7.7

Installed packages to be UPGRADED:
    fusefs-libs: 2.9.7 -> 2.9.9_1
    gawk: 4.1.4_3 -> 5.0.0
    gettext-runtime: 0.19.8.1_2 -> 0.20.1
    glib: 2.56.3_2,1 -> 2.56.3_7,1
    haproxy: 1.8.17 -> 2.0.13
    icu: 63.1_1,1 -> 66.1,1
    libdnet: 1.12_1 -> 1.13_3
    libmspack: 0.9.1 -> 0.10.1
    libssh2: 1.8.0,3 -> 1.8.2,3
    libxml2: 2.9.7 -> 2.9.10
    nginx: 1.14.2_3,2 -> 1.16.1_12,2
    open-vm-tools-nox11: 10.3.0_1,2 -> 11.0.1_3,2
    pcre: 8.42_1 -> 8.43_2
    perl5: 5.28.1 -> 5.30.2
    postfix: 3.3.3,1 -> 3.5.0,1
    python27: 2.7.15 -> 2.7.17_1
    readline: 7.0.5 -> 8.0.4
    sudo: 1.8.27 -> 1.8.31p1

Number of packages to be installed: 1
Number of packages to be upgraded: 18

The process will require 114 MiB more space.
62 MiB to be downloaded.
 
The first option didn't work for me. I see the 2nd one for the first time now, I have no clue if it works or not, the problem was solved on my side.
 
I got into this error after updating from 12.0-RELEASE to 12.1-RELEASE.
The solution that worked for me was to forcibly remove pkg

Code:
root@server:/var/db/pkg # pkg update -f
Updating FreeBSD repository catalogue...
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Fetching meta.txz: 100%    916 B   0.9kB/s    00:01
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
repository FreeBSD has no meta file, using default settings
Fetching packagesite.txz: 100%    6 MiB  70.9kB/s    01:31
pkg: repository meta /var/db/pkg/FreeBSD.meta has wrong version 2
pkg: Repository FreeBSD load error: meta cannot be loaded No error: 0
Unable to open created repository FreeBSD
Unable to update repository FreeBSD
Error updating repositories!
root@server:/var/db/pkg # pkg add -f https://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/pkg-1.14.2.txz
Certificate verification failed for /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
34374852608:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:/usr/src/crypto/openssl/ssl/statem/statem_clnt.c:1915:
Certificate verification failed for /C=US/O=Let's Encrypt/CN=Let's Encrypt Authority X3
34374852608:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:/usr/src/crypto/openssl/ssl/statem/statem_clnt.c:1915:
Certificate verification failed for /C=US/O=Let's


root@server:/var/db/pkg # pkg delete -f pkg
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
    pkg-1.10.5_5

Number of packages to be removed: 1

The operation will free 13 MiB.

Proceed with deinstalling packages? [y/N]: y
[1/1] Deinstalling pkg-1.10.5_5...
[1/1] Deleting files for pkg-1.10.5_5: 100%
root@server:/var/db/pkg # pkg update -f 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:12:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.13.2...
Extracting pkg-1.13.2: 100%
Usage: pkg update [-fq] [-r reponame]

For more information, see 'pkg help update'.
root@server:/var/db/pkg # pkg update
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    163 B   0.2kB/s    00:01
Fetching packagesite.txz: 100%    6 MiB 280.4kB/s    00:23
Processing entries: 100%
FreeBSD repository update completed. 31492 packages processed.
All repositories are up to date.
root@server:/var/db/pkg # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Updating database digests format: 100%
Checking for upgrades (19 candidates): 100%
Processing candidates (19 candidates): 100%
The following 19 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    python37: 3.7.7

Installed packages to be UPGRADED:
    fusefs-libs: 2.9.7 -> 2.9.9_1
    gawk: 4.1.4_3 -> 5.0.0
    gettext-runtime: 0.19.8.1_2 -> 0.20.1
    glib: 2.56.3_2,1 -> 2.56.3_7,1
    haproxy: 1.8.17 -> 2.0.13
    icu: 63.1_1,1 -> 66.1,1
    libdnet: 1.12_1 -> 1.13_3
    libmspack: 0.9.1 -> 0.10.1
    libssh2: 1.8.0,3 -> 1.8.2,3
    libxml2: 2.9.7 -> 2.9.10
    nginx: 1.14.2_3,2 -> 1.16.1_12,2
    open-vm-tools-nox11: 10.3.0_1,2 -> 11.0.1_3,2
    pcre: 8.42_1 -> 8.43_2
    perl5: 5.28.1 -> 5.30.2
    postfix: 3.3.3,1 -> 3.5.0,1
    python27: 2.7.15 -> 2.7.17_1
    readline: 7.0.5 -> 8.0.4
    sudo: 1.8.27 -> 1.8.31p1

Number of packages to be installed: 1
Number of packages to be upgraded: 18

The process will require 114 MiB more space.
62 MiB to be downloaded.
Same thing for me 12.0 to 12.1 and removing and then bootstrapping worked! Thanks!
 
This seems to be a chronic problem with 12.0 to 12.1 upgrades. I had 3 systems so far exhibit the same problem. The solution is

Code:
pkg bootstrap -f
pkg update -f

Then you can proceed with pkg upgrade -fy as requested by freebsd-update()
(I figured I might as well add this for myself and others since this post is the first/second result on search engines)
 
Last edited:
Back
Top