Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

postgresql - How to install Postgis to a Keg installation of [email protected] using Homebrew?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...