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/extensionWhen 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.
62 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.
2I had a similar problem with full details here. When the server is mentioned in your Postgres console, it means that you're referencing an older codebase. Stop that server and launch the correct server with the following commands.
$ brew services listThat will give you a list of database servers that are running.
$ brew services stop postgresql@<older-version>
$ brew services start postgresql 1