How to install Postgis to a Keg installation of [email protected] using Homebrew?
Asked Answered
S

4

14

I have installed [email protected] and Postgis via Homebrew. However, installing Postgis via Homebrew installs the latest version of Postgresql at 10 as dependency and pinning Postgresql at 9.6.5 blocks the install of Postgis via Homebrew.

Performing 'CREATE EXTENSION postgis;' returns:

ERROR: could not open extension control file "/usr/local/Cellar/[email protected]/9.6.5/share/[email protected]/extension/postgis.control": No such file or directory

I've also tried uninstalling the Postgresql (at 10) and editing the Postgis formula to depend on [email protected] instead of Postgresql.

This is similar to How to install Postgis to a Keg installation of [email protected] using Homebrew? but with a later keg formula

Spaetzle answered 2/11, 2017 at 15:43 Comment(2)
"asked 6 hours ago" -- I literally laughed out loud at seeing this. I'm having the exact same problem, researching it actively. (yes, I know this isn't a helpful comment...)Orvas
Another poor soul having the same question. Only saw yours after posting mine, sorry. Another possible approach might be described here but I am still hesitating to try.Koontz
A
10

I managed to do it after many combinations. In a nutshell, solution is to install the old version of the original package postgres, switch to it, and install the old version of postgis.

Install postgres

1/ Install the current version of postgres (10.1 as speaking)

brew install postgres

2/ Install the old version of postgres using its old formula. Proper link can be found using github or git log on the Tap repo (/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/).

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgresql.rb

This will install the version 9.6.5 (last one before 10.x series).

3/ Switch to it so links are defaulted to postgres 9.6

brew switch postgres 9.6.5

Install postgis

4/ Install old version of postgis (2.3). This is using the same sha version of the Formula so everything is linked correctly (using the current postgis will expect postgresql 10, so it will end up to a version mismatch when initializing extension).

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/d014fa223f77bee4b4097c5e80faa0954e28182f/Formula/postgis.rb

Use them

5/ If required initialise the DB

initdb /usr/local/var/postgres

6/ Create and use your DB

createdb mydb
psql mydb
mydb=# CREATE EXTENSION postgis;
Assuming answered 4/1, 2018 at 13:28 Comment(4)
I had to brew unlink postgres between steps 2 and 3.Jankowski
Thanks @Antwan, massive help here. I think there is a 9.6.8 in homebrew somehow/somewhere, but I think that is related to the [email protected] based installation which (as others have found too) won't work with brew switch postgresql 9.6.8. Just leaving this comment here for my future self, once I come back to it.Lagasse
Looks like installation of 10.1 also initializes a database in a new format. So I had to remove /usr/local/var/postgres and make initdb after switching to 9.6 in order to make it work (Do it on your own risk. You will lose ALL the data if you have something there)Lan
This seemed like a really good solution, and I was really hopeful it was going to work. Unfortunately for me, step (2) fails with Error: postgresql: Unsupported special dependency :pythonHahnert
S
7

Installing PEX, a package manager for Postgresql allowed me to install Postgis for the keg version of [email protected] and use CREATE EXTENSION postgis;

This isn't a Homebrew solution but after a lot of searching, it finally allowed me to use Postgis.

Spaetzle answered 3/11, 2017 at 14:46 Comment(3)
Worked brilliantly. One caveat for future searchers: don't bother trying the brew install of pex, it has the same issue that it will install PostgreSQL 10 for you (at least for now).Orvas
Worked for me. ThanksTendon
It took a lot of mucking about, but eventually I got this to work. In case anyone else runs into the same problems, here are the problems I encountered and the solutions I found to them: gist.github.com/skissane/0487c097872a7f6d0dcc9bcd120c2ccdHahnert
F
1

Hello

I ran into this same problem of multiple implementation of pgsql versions including legacy ones. So after a bit of research I would like to share my solution.

Problem:

I am working on a macbook pro 2013 with 10.11 el capitan. I am GIS developer and extensive user of homebrew. I didn't pin the postgresql package for compatibility reasons. Thus, the package got updated to postgresql version 10.5 along other packages. This caused me to be unable to use postgresql version 9.4. The cleverest solution would have been to use a brew switch postgresql 9.4.19. Except that when compiling postgis 2.5.0 from osgeo/osgeo4mac it defautls (looks for) the postgresql binary folder to install the symlinked (or not) extensions. Here again another compatibility problem. One could tinker a bit with homebrew files and transfer files manually. That's ill advice...the package manager (homebrew) needs to stay a coherent ecosystem to provide for a stable workspace.

Proposed Solution:

  1. Go here BigSQL and download the dmg of your chosen version
  2. install the software where you want in your filesystem
  3. within the installation folder you'll find a directory named pg9x ; x being the version number (e.g pg95 for postgresql 9.5 and so on...
  4. in this folder you'll find a file named pg9x.env
  5. source this file to your .profile with source /your/path/pg9x/pg9x.env line
  6. in the main installation folder, for instance /your/path/pg9x/, you'll finde a python script called pgc, alias it to your .profile with alias pgc="your/path/pgc"
  7. save your .profile and refresh your environment variable with source .profile on the command prompt
  8. still within the command prompt, type pgc list, you'll get a list of installed packages. You'll see the version of postgesql you've downloaded
  9. to install another version of postgresql, say 9.6, type pgc install pg96
  10. to install postgis for pg95 type pgc install postgis22-pg95
  11. to install postgis for pg96 type pgc install postgis23-pg96
  12. now, after installation you'll need to initialize the downloaded component with pgc init pg96 or pgc init postgis23-pg96 etc...
  13. to check if your daemon is running correctly type pgc status
  14. to start a version daemon of your choice type for example pgc start pg95
  15. to stop a version daemon of your choice type pgc stop pg95
  16. the installation also comes with an LTS release of pgadmin3 that works fine with all versions (not the case of brew version of pgadmin3), this is very convenient
  17. type pgc help for more options

Let the elephant dance^^

Hope this helps.

Spicy.

Foreigner answered 4/11, 2018 at 9:50 Comment(0)
R
0

I faced a similar issue and what worked for me was to follow the instructions at https://github.com/CloverHealth/homebrew-tap, which seem similar in spirit to @Antwan's solution but with a few more clean up steps, also it gets slightly later versions: postgresql 9.6.10 and postgis 2.5.

My steps differed slightly from those at CloverHealth: My brew version no longer supports brew switch postgresql 9.6.10 and I tried first brew link [email protected] and then brew link [email protected] but both gave

Error: no such keg

Trying brew search postgresql showed a little green checkmark next to the cloverhealth Formulae, so I tried brew link cloverhealth/tap/postgresql and got

Warning: Already linked: /usr/local/Cellar/postgresql/9.6.10

So, ok it was already linked. Other than that my steps were the same as described at the CloverHealth page, and now I'm up and running again.

Retinite answered 21/5, 2021 at 7:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.