pkg: repository archive entry is too large

Today I noticed the following message while doing pkg upgrade:

Code:
$ doas pkg upgrade; echo $?
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-ports repository catalogue...
pkg: need to re-create repo FreeBSD-ports to upgrade schema version
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01    
Fetching data: 100%  9103 KiB   1.9 MB/s    00:05    
pkg: repository archive entry is too large: data
pkg: No signature found
FreeBSD-ports repository is up to date.
All repositories are up to date.
pkg: need to re-create repo FreeBSD-ports to upgrade schema version
pkg: Repository FreeBSD-ports cannot be opened. 'pkg update' required
Checking for upgrades (0 candidates): 100%
Processing candidates (0 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.
0

So, especially the following outputs are worrying me:

Code:
pkg: need to re-create repo FreeBSD-ports to upgrade schema version
pkg: Repository FreeBSD-ports cannot be opened. 'pkg update' required

And, when running pkg update:

Code:
$ doas pkg update; echo $?
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-ports repository catalogue...
pkg: need to re-create repo FreeBSD-ports to upgrade schema version
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01    
Fetching data: 100%  9103 KiB   9.3 MB/s    00:01    
pkg: repository archive entry is too large: data
pkg: No signature found
FreeBSD-ports repository is up to date.
All repositories are up to date.
0

That pkg: repository archive entry is too large: data doesn't look good. I've removed everything under /var/db/pkg/repos/ and ran pkg update again, but to no avail, the message is still present. I've tried to "verify" the local package state, and at least the file itself appears to be OK, but I haven't check its contents yet, and wouldn't know where to begin:

Code:
$ doas sqlite3 /var/db/pkg/local.sqlite "PRAGMA integrity_check"
╭─────────────────╮
│ integrity_check                                    │
╞═════════════════╡
│ ok                                                        │
╰─────────────────╯

The pkg: need to re-create repo message is mentioned in a (very) old thread in this forum, but apparently the message vanished somehow.

Ideas welcome on what to do here, thanks!


Code:
$ doas pkg -vv
Version                 : 2.8.2
libpkg                  : 2.8.2
libarchive              : libarchive 3.8.7
sqlite                  : 3.53.2
openssl                 : OpenSSL 3.5.6 7 Apr 2026
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
INDEXDIR = "";
INDEXFILE = "INDEX-15";
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;
DEVELOPER_MODE = false;
VULNXML_SITE = "https://vuxml.freebsd.org/freebsd/vuln.xml.xz";
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/2.8.2";
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\"";

    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";
    orphans = "version -vRl?";
    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\"";
    sets = "info -d -C -x '^FreeBSD-set-'";
    shared-depends = "info -qB";
    show = "info -f -k";
    size = "info -sq";
    unmaintained = "query -e '%m = \"ports@FreeBSD.org\"' '%o (%w)'";
    runmaintained = "rquery -e '%m = \"ports@FreeBSD.org\"' '%o (%w)'";
}
CUDF_SOLVER = "";
SAT_SOLVER = "";
RUN_SCRIPTS = true;
CASE_SENSITIVE_MATCH = true;
LOCK_WAIT = 1;
LOCK_RETRIES = 5;
SQLITE_PROFILE = false;
WORKERS_COUNT = 0;
READ_LOCK = false;
IP_VERSION = 0;
AUTOMERGE = true;
MERGETOOL = "";
VERSION_SOURCE = "";
CONSERVATIVE_UPGRADE = true;
FORCE_CAN_REMOVE_VITAL = true;
PKG_CREATE_VERBOSE = false;
AUTOCLEAN = false;
AUTOREMOVE = false;

DOT_FILE = "";
DEBUG_SCHEDULER_DOT_FILE = "";
REPOSITORIES {
}
VALID_URL_SCHEME [
    "pkg+http",
    "pkg+https",
    "https",
    "http",
    "file",
    "ssh",
    "tcp",
]
WARN_SIZE_LIMIT = 1048576;
METALOG = "";
IGNORE_OSVERSION = false;
IGNORE_OSMAJOR = false;
BACKUP_LIBRARIES = false;
BACKUP_LIBRARY_PATH = "/usr/local/lib/compat/pkg";
PKG_TRIGGERS_DIR [
    "/usr/share/pkg/triggers/",
    "/usr/local/share/pkg/triggers",
]
PKG_TRIGGERS_ENABLE = true;
AUDIT_IGNORE_GLOB [
]
AUDIT_IGNORE_REGEX [
]
COMPRESSION_FORMAT = "";
COMPRESSION_LEVEL = -1;
REPO_ACCEPT_LEGACY_PKG = false;
FILES_IGNORE_GLOB [
]
FILES_IGNORE_REGEX [
]
SHLIB_PROVIDE_PATHS_NATIVE [
]
SHLIB_PROVIDE_PATHS_COMPAT_32 [
]
SHLIB_PROVIDE_PATHS_COMPAT_LINUX [
]
SHLIB_PROVIDE_PATHS_COMPAT_LINUX_32 [
]
SHLIB_PROVIDE_IGNORE_GLOB [
]
SHLIB_PROVIDE_IGNORE_REGEX [

SHLIB_PROVIDE_PATHS_COMPAT_LINUX_32 [
]
SHLIB_PROVIDE_IGNORE_GLOB [
]
SHLIB_PROVIDE_IGNORE_REGEX [
]
SHLIB_REQUIRE_IGNORE_GLOB [
]
SHLIB_REQUIRE_IGNORE_REGEX [
]
PKG_DEBUG_FLAGS [
    "all",
]
COMPRESSION_THREADS = -1;
PKG_REINSTALL_ON_OPTIONS_CHANGE = true;
TRACK_LINUX_COMPAT_SHLIBS = false;
PKG_RWHICH_DATABASE = true;
ABI = "FreeBSD:15:aarch64";
ALTABI = "freebsd:15:aarch64:64";
OSVERSION = "1501000";

Repositories:
  FreeBSD-ports-kmods: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/kmods_quarterly_1",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
  FreeBSD-base: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/base_release_1",
    enabled         : no,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkgbase-15"
  }
  FreeBSD-ports: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
 
The the error always mentions the FreeBSD-ports repo, I've disabled the same and the error is gone - but then of course the ports are gone. Running with -d4 gives more output: https://paste.debian.net/hidden/2ffffacc

The interesting part from that, maybe:

Code:
$ doas pkg -d4 update
[...]
DBG(1)[28589]> (fetch) libfetch> fetching from: https://pkgmir.geo.freebsd.org/FreeBSD:15:aarch64/latest/data.pkg with opts "i4"
DBG(1)[28589]> (fetch) Fetch: fetcher used: pkg+https
Fetching data:
DBG(1)[28589]> (fetch) Read status: 8192 over 9321846
[...]
DBG(1)[28589]> (fetch) Read status: 9321846 over 9321846
Fetching data... done
DBG(1)[28589]> PkgRepo: extracting data of repo FreeBSD-ports
DBG(1)[28702]> PkgRepo: extracting signature of repo in a sandbox
pkg: repository archive entry is too large: datapkg: No signature found

When manually fetching the data.pkg file:

Code:
$ curl -LO https://pkgmir.geo.freebsd.org/FreeBSD:15:aarch64/latest/data.pkg
$ tar --zstd -xf data.pkg
$ ls -l data*
-rw-r--r--  1 root wheel 62971704 Aug 13 17:32 data
-rw-r-----  1 root wheel  9321846 Aug 15 10:15 data.pkg
-rw-r--r--  1 root wheel      451 Jan  1  1970 data.pub
-rw-r--r--  1 root wheel      256 Jan  1  1970 data.sig

Does anyone know how to verify these files? Maybe there's some weird transmission error?
 
Last edited by a moderator:
I have no experience with aarch64 repositories, and I have no idea what causes the "too large" error message. If, with or without advice from others, the problem cannot be resolved, I'd consider deleting every package and deleting pkg and its db completely from your system. Then start afresh with installing pkg(8). Beforehand I should save all your relevant package names (using pkg prime-list is helpful here).

However, you have a misaligned repository set-up in your .conf file:
Rich (BB code):
   [...]
$ doas pkg -vv
Version                 : 2.8.2
[...]
ABI = "FreeBSD:15:aarch64";
ALTABI = "freebsd:15:aarch64:64";
OSVERSION = "1501000";

Repositories:
  FreeBSD-ports-kmods: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/kmods_quarterly_1",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
  FreeBSD-base: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/base_release_1",
    enabled         : no,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkgbase-15"
  }
  FreeBSD-ports: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
Your pkg -vv output should reflect either both using quarterly or both using latest; not a mix of both for the ports-tree repositories as shown in your output.

In, for example a local user set-up in /usr/local/etc/pkg/repos/FreeBSD.conf, using latest, you should have someting like:
Rich (BB code):
[1-0] # cat /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD-ports: {
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest",
  enabled: yes
}
FreeBSD-ports-kmods: {
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/kmods_latest_${VERSION_MINOR}",
  enabled: yes
}
FreeBSD-base: {
  url: "pkg+https://pkgbase.FreeBSD.org/${ABI}/base_release_${VERSION_MINOR}",
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/base_release_${VERSION_MINOR}",
  enabled: yes
}

This will also be reflected in a pkg -vv or pkg-repositories(8) output.
 
Last edited:
Wow, good catch. I've corrected the same and ran pkg update again:

Code:
$ doas pkg update
Updating FreeBSD-ports-kmods repository catalogue...
pkg: Repository FreeBSD-ports-kmods has a wrong packagesite, need to re-create database
Fetching meta.conf: 100%     179 B   0.2 kB/s    00:01
Fetching data: 100%    17 KiB  17.5 kB/s    00:01
Processing entries: 100%
FreeBSD-ports-kmods repository update completed. 80 packages processed.

Updating FreeBSD-ports repository catalogue...
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01
Fetching data: 100%  9103 KiB   2.3 MB/s    00:04
pkg: repository archive entry is too large: data
pkg: No signature found
FreeBSD-ports repository is up to date.
All repositories are up to date.

So, the FreeBSD-ports-kmods repository has now been refreshed properly, but that of course did nothing to the FreeBSD-ports repo, as you might have guessed.

Since this really looks like a proper bug I went ahead and opened PR 297548. Thank you for responding and catching this misaligned config!
 
But for some reason the issue is gone now -- "pkg update" with the "latest" repo configured completes just fine now. If this ever happens again I shall play around with TMPDIR but for now I can't reproduce this anymore.

(Also: how can I mark this thread as "solved"? I've read the REQUIRED READING posts but could not find anything.)
 
Adding my two cents here, in case my experience is helpful to anyone, this started occurring to me as well just now, but none of the suggested solutions were working to identify nor correct the problem, so naturally I thought my case was of a different nature, not storage capacity related, but perhaps some kind of odd data corruption somewhere. Moreover, it was occurring only in a specific jail, while all others on the same host, almost identically configured, were working just fine, and that of course confused me even more.

At the end of the day, it did turn out to be storage capacity related, but it eluded me because, silly enough, I was only looking at the pool hosting the jails, which has ample space left, but I'd forgotten that /tmp in the affected jail is a tmpfs mount, only 128MB in size; and as soon as I remembered that, I bumped it up to 256MB, restarted the jail, and the problem immediately went away, pkg update succeeded in creating its local database and package management functionality was restored.
 
After PR#297548 was closed, someone added:
Baptiste Daroussin, pkg's main developer.

I think I did see a manifestation of what he mentioned, there were at first some errors about unfetchable URLs for pkg itself, which obviously made things murkier. But then, after those went away, the "too large" and "no signature" errors that followed were certainly due to storage exhaustion.
 
I was about to re-open the bug, because it just happend again, and even switching from latest to quarterly did not help:

Code:
$ cat /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD-ports: {
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/quarterly",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
}

$ pkg upgrade
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-ports repository catalogue...
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01
Fetching data: 100%  9016 KiB   2.3 MB/s    00:04
pkg: repository archive entry is too large: data
pkg: No signature found
FreeBSD-ports repository is up to date.
All repositories are up to date.
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
pkg: Repository FreeBSD-ports cannot be opened. 'pkg update' required
vulnxml file up-to-date
Checking integrity... done (0 conflicting)
Your packages are up to date.

Monitoring the disk space on my 128 MB /tmp directory while pkg upgrade was running showed that it indeed used some space, but not too much:

Code:
$ while true; do df -h /tmp/ | grep -v File; sleep 0.05; done 
[...]
tmpfs         128M    5.8M    122M     5%    /tmp
tmpfs         128M    6.9M    121M     5%    /tmp
tmpfs         128M    6.9M    121M     5%    /tmp
tmpfs         128M    7.5M    120M     6%    /tmp
tmpfs         128M    7.5M    120M     6%    /tmp
tmpfs         128M    8.2M    120M     6%    /tmp
tmpfs         128M     52K    128M     0%    /tmp
tmpfs         128M     52K    128M     0%    /tmp

But, let's try to use a different TMPDIR anyway, as suggested by Gennady in the bug entry:

Code:
$ df -h /tmp/ /var/tmp/
Filesystem            Size    Used   Avail Capacity  Mounted on
tmpfs                 128M     52K    128M     0%    /tmp
zroot/ROOT/default     21G    5.7G     15G    28%    /

$ TMPDIR=/var/tmp/ pkg upgrade
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-ports repository catalogue...
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01
Fetching data: 100%  9016 KiB   2.3 MB/s    00:04
Processing entries: 100%
FreeBSD-ports repository update completed. 37181 packages processed.
All repositories are up to date.
Checking for upgrades (7 candidates): 100%
Processing candidates (7 candidates): 100%
The following 6 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
[...]

So, this worked, and even going back to latest worked, nice! :-)
 
Yes, setting TMPDIR to a different (bigger?) directory helped in my case. I still do not fully understand why though, because /tmp did have enough space. Or maybe not and my while loop above was not quick enough to catch it running out of space. I don't seem to be able to use truss on this system (edit: oh, because ptrace may not not implemented in arm64?) to dig deeper, so I just have to assume that my /tmp directory is maybe really too small.
 
Rich (BB code):
$ cat /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD-ports: {
  url: "pkg+https://pkg.FreeBSD.org/${ABI}/quarterly",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
}
It looks like here you may been using a misaligned pkg config setting, judging by the contents of your /usr/local/etc/pkg/repos/FreeBSD.conf (containing only the config settings for FreeBSD-ports and not FreeBSD-ports-kmods) and:
Rich (BB code):
$ pkg upgrade
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-ports repository catalogue...
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
Fetching meta.conf: 100%     168 B   0.2 kB/s    00:01
Fetching data: 100%  9016 KiB   2.3 MB/s    00:04
pkg: repository archive entry is too large: data
pkg: No signature found
FreeBSD-ports repository is up to date.
All repositories are up to date.
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
pkg: Repository FreeBSD-ports cannot be opened. 'pkg update' required
I would have expected* that
pkg: Repository FreeBSD-ports has a wrong packagesite, need to re-create database
be accompanied by:
pkg: Repository FreeBSD-ports-kmods has a wrong packagesite, need to re-create database
having switched from quarterly to latest. Additionally, because of your switch to quarterly for FreeBSD-ports when the remote FreeBSD repositories have just been updated (switched to 2026Q4), that might have resulted in significantly more packages that needed to be upgraded; although I'm not sure about the exact impact this might have had.

Please check for correctness, and in particular any alignment issues:
pkg -vv | sed -nE -e '/(OSVERSION|ABI)/ p' -e '/^Repositories:/,$ p'
awk '/^[^#]/ { print FILENAME ":", $0 }' /usr/local/etc/pkg/repos/*conf

Generally I recommend to use only one file, for example /usr/local/etc/pkg/repos/FreeBSD.conf, for all your local pkg config settings (FreeBSD-ports, FreeBSD-ports-kmods and FreeBSD-base), unless you have a particular reason to do otherwise.

Apart from the above, given the apparent space issues, using pkg-clean(8) (optionally also pkg-autoremove(8)) might give you the extra space required.

___
* I don't quite understand the last quoted line; even though you've used $ pkg upgrade, I assume you ran this command with elevated rights.
 
Indeed, /usr/local/etc/pkg/repos/FreeBSD.conf contains only information for FreeBSD-ports, and /etc/pkg/FreeBSD.conf has FreeBSD-ports-kmods and FreeBSD-base. And according to the pkg output, this issue was only about FreeBSD-ports so I concentrated on that. But, to be concise:
Code:
$ pkg -vv | sed -nE -e '/(OSVERSION|ABI)/ p' -e '/^Repositories:/,$ p'
IGNORE_OSVERSION = false;
ABI = "FreeBSD:15:aarch64";
ALTABI = "freebsd:15:aarch64:64";
OSVERSION = "1501000";
Repositories:
  FreeBSD-ports-kmods: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/kmods_latest_1",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
  FreeBSD-base: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/base_release_1",
    enabled         : no,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkgbase-15"
  }
  FreeBSD-ports: { 
    url             : "pkg+https://pkg.FreeBSD.org/FreeBSD:15:aarch64/latest",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }

$ awk '/^[^#]/ { print FILENAME ":", $0 }' /usr/local/etc/pkg/repos/*conf
/usr/local/etc/pkg/repos/FreeBSD.conf: FreeBSD-ports: {
/usr/local/etc/pkg/repos/FreeBSD.conf:   url: "pkg+https://pkg.FreeBSD.org/${ABI}/latest",
/usr/local/etc/pkg/repos/FreeBSD.conf:   mirror_type: "srv",
/usr/local/etc/pkg/repos/FreeBSD.conf:   signature_type: "fingerprints",
/usr/local/etc/pkg/repos/FreeBSD.conf:   fingerprints: "/usr/share/keys/pkg",
/usr/local/etc/pkg/repos/FreeBSD.conf:   enabled: yes
/usr/local/etc/pkg/repos/FreeBSD.conf: }
Indeed, all commands were run as root.

But yeah, the 128 MB for /tmp may just be too small and I'm thinking of resizing this, or just point TMPDIR to somewhere else for pkg operations. Thank you all for your input here!
 
Back
Top