Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 4

Can't make PostGIS 3 work on Ubuntu



I'm trying to setup PostgreSQL 12 + PostGIS 3 for my CI.

My workflow is defined as below:


    runs-on: ubuntu-latest
        image: postgres:12
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: culturinthecity_test
          - 5432/tcp
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
      - name: Checkout latest code
        uses: actions/checkout@v1
      - name: Setup Ruby
        uses: eregon/use-ruby-action@v1
          ruby-version: 2.6.5
      - name: Print Ruby version
        run: ruby -v
      - name: Install PostgreSQL 12 client required for loading structure.sql
        run: |
          sudo bash -c "echo deb bionic-pgdg main >> /etc/apt/sources.list.d/pgdg.list"
          wget --quiet -O - | sudo apt-key add -
          sudo apt-get update
          sudo apt-get -yq install libpq-dev postgresql-client-12 postgresql-12-postgis-3 postgresql-12-postgis-3-scripts

The installation works fine but when I try to load my structure.sql file, it fails with the error below when creating the postgis extension in the database.


psql:/home/runner/work/App-NE/App-NE/db/structure.sql:30: ERROR:  could not open extension control file "/usr/share/postgresql/12/extension/postgis.control": No such file or directory

When looking into /share/postgresql/12/extension, I have two files:


  • postgis-3.control
  • postgis.control


The second file is setup during installation and is a symlink to another file containing the following info:


# postgis extension
comment = 'PostGIS geometry, geography, and raster spatial types and functions'
default_version = '3.0.0'
module_pathname = '$libdir/postgis-3'
relocatable = false

I don't understand why it doesn't work.


Do you have any input on the subject?



3 Replies
GitHub Partner
Message 2 of 4

Re: Can't make PostGIS 3 work on Ubuntu

I tested with the same workflow definition you shared, it can run successfully without any error.

When you run the command find /usr -name postgis.control, whether it will return the result like as “/usr/share/postgresql/12/extension/postgis.control”?

If it return nothing, this may be due to the postgis-scripts is not installed. You can execute the command aptitude search postgis to check it. if the postgis-scripts has been installed, in the returned results of this command, you can find the below item:

i  postgresql-12-postgis-3-scripts - Geographic objects support for PostgreSQL 12 -- SQL scripts

If the postgis-scripts is not installed, run the command sudo apt-get install postgis postgresql-12-postgis-scripts to install it.


There is a ticket reported the similar problem:

Copilot Lvl 2
Message 3 of 4

Re: Can't make PostGIS 3 work on Ubuntu



I have the same result as you but have you tried running `CREATE EXTENSION postgis;` in the database?

GitHub Partner
Message 4 of 4

Re: Can't make PostGIS 3 work on Ubuntu

You can try the workaround mentioned by ethomson in this ticket that manually install the package that contains postgis.control by executing the following command:

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