Search code examples
postgresqlazure-devopspostgis

postgresql/postgis looking for wrong version folder when creating extension in Azure DevOps pipeline


I'm building a pipeline on Azure DevOps with a Linux image as a base (ubuntu-latest). Here I'm installing PostgreSQL version 12 with PostGIS. Here's what I install:

sudo apt-get install -y postgresql-12 postgresql-client-12 postgresql-12-postgis-3 postgresql-12-postgis-3-scripts

First I tried to install it without mentioning any version numbers, but then I got the error mentioned below and I followed recommendations to specifically do it like this. Hence the specifically mentioned version numbers No special additions, just a plain installation of Postgres.

Installation is going fine without any errors.

Then when I create my database and connect to it, I do CREATE EXTENSION POSTGIS; and I get this error:

psql:./create_tables.sql:3: ERROR:  could not open extension control file "/usr/share/postgresql/14/extension/postgis.control": No such file or directory

I'm pulling my hair for some time now about this and I totally don't get where it gets that reference to a version 14 folder from. There is absolutely no version 14 installed. I also tried to pull the Debian packages from the Postgres.org instead of the Ubuntu libraries, I tried to install PostGIS 2.5 and PostGIS 2.5 scripts packages. But whatever I do, I get the same result. Once I start the pipeline, the image gets built and Postgresql and PostGIS installed and then I get the same error as a result. Did anyone have this same experience? Where could this library folder reference for version 14 come from?

EDIT 2022/05/21: I've added some checks to the scripts and when checking the version of PostgreSQL(via SELECT version(); ) it gives version 14 (!), which at least explains the error. Apparently version 14 indeed IS installed and runs on the default port 5432. Version 12 that is explicitly installed also runs, it runs on port 5433 (checked via cat /etc/postgresql/12/main/postgresql.conf ). I now explicitly start version 12 and connect in my scripts to port 5433, so I can continue, but I still wonder where that version 14 installation comes from.


Solution

  • Postgres 14 is pre-installed on the Microsoft Hosted agent for ubuntu-20

    Reference: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#postgresql