12

I am receiving this error when I create extension postgis;:

SQL Error [58P01]: ERROR: could not open extension control file "C:/POSTGR~1/10.5/pg10/../pg10/share/postgresql/extension/postgis.control": No such file or directory

The cause appears to be an incorrect path (an extra postgresql). It should be:
"C:/POSTGR~1/10.5/pg10/../pg10/share/extension/postgis.control"

This PostGIS installer that I used is: http://download.osgeo.org/postgis/windows/pg10/postgis-bundle-pg10x64-setup-2.5.0-1.exe

And I am running PostgreSQL 10.5 on x86_64-pc-mingw64, compiled by gcc.exe (Rev5, Built by MSYS2 project) 4.9.2, 64-bit

While my question is a near duplicate of https://gis.stackexchange.com/a/71476/31, the issue is specific to PostgreSQL 10/PostGIS 2.5, and I don't think the answer is necessarily the same (since there is no spatial_ref_sys.sql file).

Is there way to correct the error? If not, which files in the extension directory have to run (and in which order) to create the PostGIS extension?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 12, 2018 at 18:08
1
  • 1
    Unfortunately I still ran in the middle of 2019 in this mistake. First of all, it's not a special PG10/PostGIS-2.5 problem. I tested several combinations with Ubuntu under Docker. The problem are the missing links at the expected location. Sadly Postgres has the version number in the path. The solution is still the exact installation with the version numbers. Especially the package postgresql-XX-postgis-Y.Z-scripts provides the matching file associations. Here is the installation part of a working Dockerfile: ``` FROM ubuntu:18.04 RUN apt-get update && apt-get install -y \ software-propertie Commented Jul 8, 2019 at 12:36

4 Answers 4

11

I found this question and answer on stackoverflow.com for PostgreSQL 9.6: https://stackoverflow.com/questions/42806784/how-to-alter-the-path-for-postgres-looking-for-extensions.

This answer also works for PostgreSQL 10.

I first moved all files from .\share\extension to .\share\postgresql\extension and re-ran the create extension postgis. As expected, I received this error: ERROR: could not access file "$libdir/postgis-2.5": No such file or directory. Which I figured, but I wanted to see what the exact error would be.

Then I moved the files in .\lib into .\lib\postgresql and now the create extension postgis works.

answered Oct 14, 2018 at 22:54
5

The command below resolved my case:

sudo apt install postgresql-10-postgis-scripts
answered Aug 11, 2019 at 4:38
4

Download binary of the desired version of postgis and add extensions files in lib and share/extension folder of postgresql. Hopefully, this issue will be resolved.

answered Oct 13, 2018 at 5:20
1
  • https://anaconda.org/conda-forge/postgis/files?type=conda, in win location : ..anaconda3\envs\...\Library\share\extension Commented May 4, 2021 at 16:34
2

For windows, use stackbuilder > spatial extensions > PostGIS 3.1 Bundle for PostgreSQL

answered Mar 15, 2021 at 16:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.