Solved pkg upgrade tries to install postgresql15-client when postgresql16-client already installed

I uncounted an error where pkg upgrade tries to install postgresql15-client package when I don't need it installed.

Code:
 % sudo pkg upgrade                                                                                                                               
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating random repository catalogue...
random repository is up to date.
All repositories are up to date.
Checking for upgrades (219 candidates): 100%
Processing candidates (219 candidates): 100%
Checking integrity... done (3 conflicting)
  - postgresql15-client-15.7 [FreeBSD] conflicts with postgresql16-client-16.4 [installed] on /usr/local/bin/clusterdb
  - postgresql15-client-15.7 [FreeBSD] conflicts with postgresql16-client-16.4 [random] on /usr/local/bin/clusterdb
  - postgresql15-client-15.8 [random] conflicts with postgresql16-client-16.4 [installed] on /usr/local/bin/clusterdb
Checking integrity... done (0 conflicting)
The following 48 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        grpc: 1.62.2_3,2 [random]
        postgresql15-client: 15.8 [random]



I have already upgraded my postgresql instance to 16. and it doesn't look like anything should need postgresql15-client.

Code:
  % pkg info -r postgresql15-client                                                                                                               
pkg: No package(s) matching postgresql15-client

  % pkg info -r postgresql16-client                                                                                                                
postgresql16-client-16.4:
        dovecot-2.3.21_6
        postgresql16-contrib-16.3
        postgresql16-server-16.4


How to I figure out what is requesting the install of postgresql15-client when it isn't current installed?
 
In /usr/ports/UPDATING is:
Code:
20240723:
  AFFECTS: users of databases/postgresql* and other software using PostgreSQL to run
  AUTHOR: [email]kbowling@FreeBSD.org[/email]

  The default version of PostgreSQL has been switched from 15 to 16.
  The upgrade procedure can use up twice the space the databases
  currently needs. If you have a big amount of stored data take a
  closer look at the manpage of pg_upgrade for avoidance and/or
  speedup of the upgrade.

  The upgrade instructions consider a basic usage and do not match
  complex scenarios like replication, sharding, or similar.

  Upgrade instructions:

  First stop your PostgreSQL, create PostgreSQL-binaries and backup your data.
  If you have another Version of PostgreSQL installed, for example 15, your
  files are named according to this.

  # service postgresql stop
  # pkg create postgresql15-server postgresql15-contrib
  # mkdir /tmp/pg-upgrade
  # tar xf postgresql15-server-15.7.pkg -C /tmp/pg-upgrade
  # tar xf postgresql15-contrib-15.7.pkg -C /tmp/pg-upgrade
  # pkg delete -f databases/postgresql15-server databases/postgresql15-contrib databases/postgresql15-client

  Now update PostgreSQL:

    pkg user:
    # pkg install databases/postgresql16-server databases/postgresql16-contrib
    # pkg upgrade

    Portmaster users:
    # portmaster databases/postgresql16-server databases/postgresql16-contrib
    # portmaster -a

    Portupgrade users:
    # portinstall databases/postgresql16-server databases/postgresql16-contrib
    # portupgrade -a

  After installing the new PostgreSQL version you need to convert
  all your databases to new version:

  # su -l postgres -c "/usr/local/bin/initdb --encoding=utf-8 --lc-collate=C -D /var/db/postgres/data16 -U postgres"
  # su -l postgres -c "pg_upgrade -b /tmp/pg-upgrade/usr/local/bin/ -d /var/db/postgres/data15/ -B /usr/local/bin/ -D /var/db/postgres/data16/ -U postgres "

  Now the migration is finished. You can start PostgreSQL again with:

  # service postgresql start

  ATTENTION:
  1) If you use non-default initdb options, you have to adjust the initdb-command accordingly
 
It's not about upgrading from 15 to 16, the OP succeeded in that. The 'problem' is mixing latest (defaults to 16) and quarterly (defaults to 15).
 
Doesn't the pkg info command only look at currently installed packages, not in the repo? If so and OP does not currently have postgresql15-client install then the "-r" option won't show anything.
 
Are you mixing quarterly packages with latest ports? Because 15 is still the default on quarterly.

Yes I believe I did mix quarterly and latest unintentionally. I switched from building my own ports to using poudriere and pkg. It looks like I didn't set this up correctly. I did try changing the PGSQL_DEFAULT?= 16 in /usr/ports/Mk/bsd.default-versions.mk which didn't have an effect. How do I clean up the mess I made? :)
Is there any locked pkg?
I tried locking postgresql15-client so it would not be installed but that did not work either. Other than that there were no locked pkgs.
 
I switched from building my own ports to using poudriere and pkg.
Ok, that's fine. Did you checkout a quarterly ports tree with poudriere?

I did try changing the PGSQL_DEFAULT?= 16 in /usr/ports/Mk/bsd.default-versions.mk which didn't have an effect.
Do not edit Mk/bsd.default-versions.mk.

If you used a quarterly tree, set this in /usr/local/etc/poudriere.d/make.conf:
Code:
DEFAULT_VERSIONS+= pgsql=16
That will switch the default PGSQL version to 16. Then start a bulk build with poudriere. That should rebuild all packages that have a dependency on the postgresql client and pull in the correct version.

On the 'client' hosts, disable the FreeBSD repository and only enable your custom repo. They have conflicting options now, if you enable them both you're going to get some bad results.
 
I had that too, with several machines which never seen quarterly.

My fix is to nuke the old client package, do a full update, reinstall the client. Now you have the new one with no clashes.
 
Ok, that's fine. Did you checkout a quarterly ports tree with poudriere?
No, I want to use the latest version of the ports tree and not the quarterly ports.

I don't have a /usr/local/etc/poudrere.d/make.conf. Should I add one with DEFAULT_VERSIONS+= pgsql=16 and build my packages?
I'll disable the FreeBSD repository and see how that works.
 
If you're using a latest ports tree, then you don't have to set PGSQL to 16, it's already the default there.

But you're going to need to disable the FreeBSD repository on the clients, because that defaults to quarterly packages. That will get you conflicting defaults because PGSQL is still at 15 there.

Disabling the FreeBSD repository is simple, just add a /usr/local/etc/pkg/repos/FreeBSD.conf and put this in it:
Code:
FreeBSD: { enabled: no }
 
When switching to a different (self maintained) pkg repository it is usually a good idea to run pkg upgrade -f to reinstall everything from the new repository, then purge out any possibly orphaned dependencies with pkg autoremove.
 
Back
Top