Postgresql – Postgres on OS X can’t find postgis extension control file

postgispostgresql

Using mac OSX Yosemite 10.10.1. I uninstalled and re-installed both postgres and postgis with homebrew. I understand that postgres is looking in the wrong place for the postgis control file. Also noticed that 'which psql' path seems incorrect. How/where do I fix this?

psql

(9.4.0, server 9.3.5)

ERROR:  could not open extension control file "/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql/extension/postgis.control": No such file or directory

find /usr -name postgis.control

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

which psql

/usr/local/bin/psql

which pg_config

/usr/local/bin/pg_config

brew info postgis

postgis: stable 2.1.5, HEAD
http://postgis.net
/usr/local/Cellar/postgis/2.1.5 (45 files, 8.6M) *
  Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgis.rb

brew info postgres

postgresql: stable 9.4.0 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.4.0 (3049 files, 74M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb

Both .bashrc and .bash_profile have

export PGDATA='/usr/local/Cellar/postgresql/9.4.0/bin/postgres'
alias postgres-log='cd /usr/local/var/postgres/ && subl server.log'

mdfind -name "postgres" | grep -G "postgres$"

/usr/local/Cellar/postgresql/9.4.0/bin/postgres
/usr/local/var/postgres
/Users/lionelramos/macports/var/macports/sources/rsync.macports.org/release/tarballs/ports/ruby/rb-postgres

Looks like I have different a local version of postgres in addition to the homebrew version.

Best Answer

How I solved my problem:

  1. I uninstalled postgres 9.3.5_1 with brew uninstall postgres 9.3.5_1.
  2. I uninstalled postgis with brew uninstall postgis
  3. Made sure that I only had postgres 9.4 installed with brew info postgres
  4. Made sure that psql command worked.
  5. I reinstalled postgis with brew install postgis.

This solved my problem. If you're having trouble with step 4 you might need to use initdb or createdb commands to create database needed.