How to alter the path for Postgres looking for extensions?

TomGeo picture TomGeo · Mar 15, 2017 · Viewed 14.5k times · Source

I installed Postgres on a Windows machine, downloaded the binary installer for PostGIS and installed it. I only have one version of Postgres, so there is no messing up possible.

Installing PostGIS using the binary installer is straight forward and you cannot mess up the installation directory either. it has to go into the Postgres directory.

Now, when I want to create the PostGIS extension I am getting the following error:

ERROR:  could not open extension control file "C:/APPS/POSTGR~1/pg96/../pg96/share/postgresql/extension/postgis.control": No such file or directory
********** Error **********

ERROR: could not open extension control file "C:/APPS/POSTGR~1/pg96/../pg96/share/postgresql/extension/postgis.control": No such file or directory
SQL state: 58P01

Though when I go into the directory C:\APPS\PostgreSQL\pg96\share\extension then I do have a postgis.control file present.

How do I get the extension to work? I checked the content of the zipped PostGIS binaries and it looks like as if the structure is well preserved and all files are copied into the appropriate directories during the install process via the binary installer.

Answer

LKallipo picture LKallipo · Jul 19, 2017

It seems that the case is still the same with latest versions of postgres (PostgreSQL-9.6.3-1-win64-bigsql.exe) and postgis (postgis-bundle-pg96x64-setup-2.3.2-1.exe). I copied the files around until all the paths could be resolved:

  1. Everything from C:\PostgreSQL\pg96\share\extension to C:\PostgreSQL\pg96\share\postgresql\extension
  2. postgis_topology-2.3.dll, postgis-2.3.dll, rtpostgis-2.3.dll, address_standardizer-2.3.dll and ogr_fdw.dll from C:\PostgreSQL\pg96\lib to C:\PostgreSQL\pg96\lib\postgresql