Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Postgis extension: "ERROR: could not open extension control file"

I am getting the following error when I run create extension postgis;

ERROR: could not open extension control file "/Library/PostgreSQL/9.6/share/postgresql/extension/postgis.control": No such file or directory

I am using Postgres 9.6.3 and PostGIS 2.3.2 installed using Homebrew on OS X El Capitan.

mdfind -name postgis.control shows:

/usr/local/Cellar/postgis/2.3.2/share/postgresql/extension/postgis.control

brew info postgis shows:

PostGIS extension modules installed to:
/usr/local/share/postgresql/extension

When I start the Postgres console I see:

psql (9.6.3, server 9.6.1)

I read a similar question, PostGIS Homebrew installation referencing an old path?, and tried to reload postgresql using the commands given in the top answer, but I am still seeing psql (9.6.3, server 9.6.1). Also, I believe my issue is different because it's looking for the extension control file in /Library and not /usr/local/Cellar.

Any help would be appreciated.

like image 249
Fiona Avatar asked Jun 30 '17 17:06

Fiona


People also ask

What is PostGIS extension?

PostGIS is an extension to PostgreSQL for storing and managing spatial information. To learn more about PostGIS, see PostGIS.net . Starting with version 10.5, PostgreSQL supports the libprotobuf 1.3. 0 library used by PostGIS for working with map box vector tile data.


1 Answers

When you try to install postgis it install latest version of postgresql along with it as dependency. So if you installed postgres@V (where V is user desired version )

brew install postgresql@V

later you run this command

brew install postgis

it will install postgres10.1 or whatever is latest. So after that if run

create extension postgis;

In postgresql@V it will try to check its extension directory and it won't find postgis.control in extension directory as this postgis is installed in extension folder of postgresql version that is installed with that.

To solve this problem, you have to create a symlink from given installation of postgis to the desired postgresql@V

This example for [email protected]

ln -s  /usr/local/share/postgresql/extension/postgis* /usr/local/Cellar/[email protected]/9.6.6/share/[email protected]/extension/
ln -s /usr/local/lib/postgresql/postgis-2.3.so /usr/local/Cellar/[email protected]/9.6.6/lib/postgis-2.3
ln -s /usr/local/lib/postgresql/rtpostgis-2.3.so /usr/local/Cellar/[email protected]/9.6.6/lib/

before running these commands, please check postgresql version and file path in your system

Thanks this gist for help.

like image 167
abby37 Avatar answered Sep 23 '22 08:09

abby37