Postgis is not installed to old Postgresql@9.5


I have installed Postgresql@9.5 but upon checking, it has been installed to /usr/local/Cellar/postgresql@9.5/9.5.6/ instead of /usr/local/Cellar/postgresql/9.5.6/. Upon installation of Postgis, it installed a new postgresql installation to /usr/local/Cellar/postgresql/9.6.2 instead of installing it to Postgresql@9.5

(Franklin Yu) #2

It is expected. The postgresql@9.5 formula only keeps the 9.5 branch. 9.6 is the latest branch. Does that cause any real issue? Does PostGIS complain?


The problem is that the Postgis doesn’t install to that older version of Postgres. Instead, it install the newer version Postgresql which is 9.6.2

(Franklin Yu) #4

So 9.6.2 doesn’t work?


We need a specific version of Postgresql which is 9.5.

(Franklin Yu) #6

Do you mean that generally latest PostGIS will break with the PostgreSQL 9.6, or specifically you need PostgreSQL 9.5 for some other reason (like something in your specific project that will break in PostgreSQL 9.6)?

If it’s the second case, I think there may be a way to configure your application/project so that PostgreSQL 9.5 is used. I’m not familiar with PostGIS; I assume that it’s an extension of PostgreSQL that works with any recent version of PostgreSQL. Is there another program that uses PostgreSQL, written in PHP/Python/Ruby (or even C)? Maybe you can tell it the path to the PostgreSQL binary/library/header?


What I mean is that the lastest Postgis breaks Postgresql 9.5. No other program uses Postgresql.

ERROR: could not open extension control file “/usr/local/Cellar/postgresql@9.5/9.5.6/share/postgresql@9.5/extension/postgis.control”: No such file or directory

Here is where the latest Postgis installed the postgis.control


(Franklin Yu) #8

Sorry I got even more confused. So does PostGIS work with PostgreSQL 9.6?


Latest Postgis 2.3.3 works with latest Postgresql 9.6.2, but it doesn’t work with Postgresql 9.5.

(Franklin Yu) #10

Ok thanks. So you want to use PostgreSQL 9.5 for your personal reason, right?

Would you like to share where you got the error message (for example, when running psql)?


The error appears when running CREATE EXTENSION postgis; from psql

(Franklin Yu) #12

That’s the issue. I guess CREATE EXTENSION postgis; only looks for extension located in the Keg, while the postgis Formula only installs the control file in /usr/local/share/postgresql/extension (by this line). Does it work if you simply symlink /usr/local/Cellar/postgresql@9.5/9.5.6/share/postgresql@9.5/extension/postgis.control to /usr/local/Cellar/postgis/2.2.2/share/postgresql/extension/postgis.control?


This seems not to work.

At my local mac symlinking in that file will follow to an error where it misses “postgis–2.4.0.sql”

symlinking in “/usr/local/Cellar/postgis/2.4.0/share/postgresql/extension/postgis–2.4.0.sql”

will result in the next error
postgres=# CREATE EXTENSION postgis;
ERROR: syntax error at or near “PARALLEL”

Pretty frustrating.

Ok. You guys talk about a postgis version 2.2.2. That version is not available to be installed by homebrew anymore.

Or am I wrong? Is there anyone out there who installed an older version of postgresql (9.5) with extension postgis?

(Ray Wu) #14

@greyshine this seems to address your problem. I’m trying to find the postgis 2.2.2 version on homebrew-core, too


I found a link to postgis 2.2.2_3



  • I gave up using brew to manage different versions of postgres, postgresql@9.5, etc.
  • extensions, such as postgis, installed through homebrew are expecting pg_config to be at default bin, and not the running version of postgresql
  • I tried pex but it installed the latest version of postgis at the correct postgresql bin, but the versions are not compatiable
  • I downloaded instead