Solved pkg mismatch when upgrading

Although, a similar problem is shown as solved in an older thread. The solution is not shown (or at least understood by me).
The problem is, I get the message below when trying to run pkg upgrade.
I did upgrade the system to 13.2 using fetch which seemed to go OK, but when I run pkg upgrade again, I still get this same message.
The latest download running fetch is: 13.2-RELEASE_2023-08-13_162349, and uname -a gives
13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64
Although I'm a newbie (especially in this area) I am mystified.
All help appreciated.
Code:
Newer FreeBSD version for package zziplib:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1302001
- running kernel: 1301000
Ignore the mismatch and continue? [y/N]: n
pkg: repository FreeBSD contains packages for wrong OS version: FreeBSD:13:amd64
Processing entries: 100%
Unable to update repository FreeBSD
Error updating repositories!
 
Have a look at,
Code:
freebsd-version -kru
pkg -vv
Alain,
Thanks for your very rapid reply, but I'm afraid I do not understand information in the answers.
I hope you can point me in the right direction.
=========================================================

Code:
freebsd-version -kru
13.2-RELEASE-p2
13.2-RELEASE
13.2-RELEASE-p2
Code:
pkg -vv
Version                 : 1.19.2
PKG_DBDIR = "/var/db/pkg";
PKG_CACHEDIR = "/var/cache/pkg";
PORTSDIR = "/usr/ports";
INDEXDIR = "";
INDEXFILE = "INDEX-13";
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:13:amd64";
ALTABI = "freebsd:13:x86:64";
DEVELOPER_MODE = false;
VULNXML_SITE = "[URL]http://vuxml.freebsd.org/freebsd/vuln.xml.xz[/URL]";
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.19.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\"";
    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\"";
    shared-depends = "info -qB";
    show = "info -f -k";
    size = "info -sq";
    unmaintained = "query -e '%m = \"[email]ports@FreeBSD.org[/email]\"' '%o (%w)'";
    runmaintained = "rquery -e '%m = \"[email]ports@FreeBSD.org[/email]\"' '%o (%w)'";
}
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;
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",
    "tcp",
]
ALLOW_BASE_SHLIBS = false;
WARN_SIZE_LIMIT = 1048576;
METALOG = "";
OSVERSION = 1301000;
IGNORE_OSVERSION = false;
BACKUP_LIBRARIES = false;
BACKUP_LIBRARY_PATH = "/usr/local/lib/compat/pkg";
PKG_TRIGGERS_DIR = "/usr/local/share/pkg/triggers";
PKG_TRIGGERS_ENABLE = true;
AUDIT_IGNORE_GLOB [
]
AUDIT_IGNORE_REGEX [
]
COMPRESSION_LEVEL = -1;
ARCHIVE_SYMLINK = false;
REPO_ACCEPT_LEGACY_PKG = false;
FILES_IGNORE_GLOB [
]
FILES_IGNORE_REGEX [
]


Repositories:
  FreeBSD: {  
    url             : "pkg+[URL]http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly[/URL]",
    enabled         : yes,
    priority        : 0,
    mirror_type     : "SRV",
    signature_type  : "FINGERPRINTS",
    fingerprints    : "/usr/share/keys/pkg"
  }
 
What is the output when /usr/bin/file /usr/bin/uname is run?
/usr/bin/uname: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically l
inked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.1, FreeBSD-style, stripped

And I have to admit, that is completely beyond my understanding.
 
/usr/bin/uname: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically l
inked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.1, FreeBSD-style, stripped
Looks like another botched upgrade. You probably ran freebsd-update install only once after the upgrade from 13.1 to 13.2. You need to run freebsd-update install twice.
 
Check your /usr/local/etc/pkg.conf. Remove it if it's set there.
This OSVERSION is from the binary header of /usr/bin/uname, not from the configuration file.
pkg.conf(5)
Code:
ABI: string
         Default: derived from the ABI of the /usr/bin/uname binary,
It is not the output of uname(1), but /usr/bin/uname itself.

For example, in my system

Code:
~> file /usr/bin/uname
/usr/bin/uname: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.2, FreeBSD-style, stripped

~> pkg config osversion
1302001

~> pkg info python27

Annotations    :
        FreeBSD_version: 1300139

~> pkg -o ABI_FILE=/usr/local/bin/python2.7 config osversion
1300139
see
Re: pkg thinks kernel is old
host-and-jail-version-are-the-same-but-differ-from-pkg-osversion
 
Looks like another botched upgrade. You probably ran freebsd-update install only once after the upgrade from 13.1 to 13.2. You need to run freebsd-update install twice.
Thanks, you may be right, but just tried as follows:
=======================================
Code:
freebsd-update install
No updates are available to install.
Run '/usr/sbin/freebsd-update fetch' first.
root@4Dec22:/usr/home/murf # freebsd-update fetch
Looking up update.FreeBSD.org mirrors... 2 mirrors found.
Fetching metadata signature for 13.2-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.
Preparing to download files... done.
The following files are affected by updates. No changes have
been downloaded, however, because the files have been modified
locally:
/etc/ssh/sshd_config
/var/db/etcupdate/current/etc/ssh/sshd_config
/var/db/mergemaster.mtree

No updates needed to update system to 13.2-RELEASE-p2.
But I still get this:
Code:
pkg update
Updating FreeBSD repository catalogue...
Fetching packagesite.pkg: 100%    7 MiB   7.0MB/s    00:01    
Processing entries:   0%
Newer FreeBSD version for package zziplib:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1302001
- running kernel: 1301000
Ignore the mismatch and continue? [y/N]: n
pkg: repository FreeBSD contains packages for wrong OS version: FreeBSD:13:amd64
Processing entries: 100%
Unable to update repository FreeBSD
Error updating repositories!
I must admit to being completely lost. What does this message mean?
Code:
The following files are affected by updates. No changes have
been downloaded, however, because the files have been modified
locally:
/etc/ssh/sshd_config
/var/db/etcupdate/current/etc/ssh/sshd_config
/var/db/mergemaster.mtree
 
Here's what likely happened, you ran freebsd-update -r 13.2-RELEASE upgrade to upgrade the system to 13.2. You then ran freebsd-update install just once. This only upgraded the kernel. After some time you ran freebsd-update fetch install to install the p2 update for 13.2. This should actually warn you that you didn't finish the upgrade yet. But you probably ignored that and went ahead anyway.

How to fix this mess? Restart the upgrade process and actually finish it this time. Run freebsd-update --currently-running 13.1-RELEASE -r 13.2-RELEASE upgrade. After it is done run freebsd-update install twice. Don't restart after the first install, ignore the message telling you to reboot and just run the second freebsd-update install. When that's finished you can reboot.
 
Here's what likely happened, you ran freebsd-update -r 13.2-RELEASE upgrade to upgrade the system to 13.2. You then ran freebsd-update install just once. This only upgraded the kernel. After some time you ran freebsd-update fetch install to install the p2 update for 13.2. This should actually warn you that you didn't finish the upgrade yet. But you probably ignored that and went ahead anyway.

How to fix this mess? Restart the upgrade process and actually finish it this time. Run freebsd-update --currently-running 13.1-RELEASE -r 13.2-RELEASE upgrade. After it is done run freebsd-update install twice. Don't restart after the first install, ignore the message telling you to reboot and just run the second freebsd-update install. When that's finished you can reboot.
Many thanks. I will try this tomorrow (Australian time) and report back. I appreciate the time you've devoted to this. Thanks.
********
Later: Yup, it worked. Thanks very much, it was driving me crazy. I'm still trying to understand it all - but I'll get there.
During the process, the upgrade merged a couple of files, which I didn't quite understand - but it worked.
The lesson I took from this is to use your freebsd-update --currently-running 13.1-RELEASE -r 13.2-RELEASE upgrade. Which is specific.
Thanks again.
Marked as Solved
 
Run freebsd-update --currently-running 13.1-RELEASE -r 13.2-RELEASE upgrade. After it is done run freebsd-update install twice. Don't restart after the first install, ignore the message telling you to reboot and just run the second freebsd-update install. When that's finished you can reboot.

Regarding your advice to not reboot after the first freebsd-update install, and to run it again without rebooting:
Is this because the kernel is already upgraded in this situation and therefore the reboot is not necessary? (What is the purpose of rebooting in the first place?)

I arrived at this thread because I was attempting to follow the instructions described in the Klara blog post about using the -t flag for bectl as part of an OS upgrade: https://klarasystems.com/articles/managing-boot-environments/

I appreciate Klara's blog posts because they're generally very informative, but in this case I believe the Klara instructions are wrong--performing an OS upgrade as described will land you in this broken upgrade state.

Klara has updated their web site and removed the comments section on the blog post, which had comments from users complaining about broken upgrades. Although the comments section was removed, they didn't bother to take the time to correct the blog post, which is unfortunate.
 
Is this because the kernel is already upgraded in this situation and therefore the reboot is not necessary? (What is the purpose of rebooting in the first place?)
The safest way is rebooting after the kernel got updated. But this has really only been a necessity when FreeBSD 5.0 came with a new version of UFS. If you didn't activate the new kernel before writing the rest of the world the whole system would be hosed. But since then there haven't been any major kernel changes that would necessitate this first reboot. So not rebooting after the kernel update and install world directly after it should be fine in most cases.
 
Regarding your advice to not reboot after the first freebsd-update install, and to run it again without rebooting:
Is this because the kernel is already upgraded in this situation and therefore the reboot is not necessary? (What is the purpose of rebooting in the first place?)
Yes. And yes, the purpose is exactly that installing the new userland on the running old kernel will very likely fail.

I arrived at this thread because I was attempting to follow the instructions described in the Klara blog post about using the -t flag for bectl as part of an OS upgrade: https://klarasystems.com/articles/managing-boot-environments/

I appreciate Klara's blog posts because they're generally very informative, but in this case I believe the Klara instructions are wrong--performing an OS upgrade as described will land you in this broken upgrade state.
They describe a way to upgrade a newly created boot environment, so, NOT your currently running system. In that case, nothing can go wrong by just installing everything at once there, no extra reboot needed.

I use the same thing with upgrading from source, in a nutshell:
Bash:
bectl create new
bectl mount new /mnt
make -C /usr/src BATCH_DELETE_OLD_FILES=yes DESTDIR=/mnt installkernel installworld delete-old delete-old-libs
etcupdate -D /mnt
ectupdate resolve -D /mnt
pkg -c /mnt upgrade -f
pkg -c /mnt autoremove
pkg -c /mnt clean
bectl umount new
bectl activate -t new
shutdown -r now
→ full system upgrade into a new BE including reinstallation of all packages without any intermediate reboot.
 
But since then there haven't been any major kernel changes that would necessitate this first reboot. So not rebooting after the kernel update and install world directly after it should be fine in most cases.
It's unlikely to "hose your system" indeed, but crashes (of individual userspace processes) might happen, and at least, the system won't be fully usable unless rebooted, because syscalls indeed change and the new userland will probably expect a kernel ABI that isn't there yet...

I'd strongly recommend to always first boot into the new kernel when upgrading the live system currently running. When upgrading a new boot environment, not the one that's currently running, that's of course completely unnecessary.
 
It's unlikely to "hose your system" indeed, but crashes (of individual userspace processes) might happen, and at least, the system won't be fully usable unless rebooted, because syscalls indeed change and the new userland will probably expect a kernel ABI that isn't there yet...

I'd strongly recommend to always first boot into the new kernel when upgrading the live system currently running. When upgrading a new boot environment, not the one that's currently running, that's of course completely unnecessary.
So if doing freebsd-update upgrade to a new RELEASE on the mounted boot environment, ignore the reboot message and run freebsd-update install twice?
 
The kernel is generally not the problem. The early dynamic C libraries are what breaks packages that are too new for the system, or more specifically the userland.

Insofar a reboot isn't even required most of the time as long as you successfully updated the base system's userland.
 
Thanks for all the responses here.

They describe a way to upgrade a newly created boot environment, so, NOT your currently running system. In that case, nothing can go wrong by just installing everything at once there, no extra reboot needed.

Since I referenced the article that caused my confusion, based on what I've learned here, I think it is fair to say the article should be updated.

In the example, "Example: Testing an OS Upgrade", the section "Next, repeat the command, this time with install:" the line should read:

freebsd-update -b /tmp/be_mount.JO5Y -d /tmp/be_mount.JO5Y/var/db/freebsd-update -r 13.0-RELEASE install

freebsd-update -b /tmp/be_mount.JO5Y -d /tmp/be_mount.JO5Y/var/db/freebsd-update install

And then should have another section explaining that the user should ignore the message from freebsd-update about rebooting, since the example is upgrading a newly created BE and not the running system, and an instruction to run the install command again before using the ZFS bootonce feature developed at Klara ( bectl activate -t [BE name]).
 
Back
Top