[GIS] Setting up PostGIS: Postgres can’t see the PostGIS extensions

installationosxpostgispostgresql

I've just installed Postgres 9.3.4 and PostGIS 2.1 on OSX Mavericks using the very latest versions of the KyngChaos libraries. This is a new machine, and I deliberately haven't installed Postgres using Homebrew or Macports.

However, when I try to create spatial extensions on a database, I can't, because Postgres claims not to be able to see the extension file:

:~ anna$ psql -d land -c "CREATE EXTENSION postgis;"
ERROR:  could not open extension control file 
"/usr/local/Cellar/postgresql/9.3.4/share/postgresql/extension/postgis.control":
No such file or directory

It looks as though the file is located somewhere else:

:~ anna$ mdfind postgis.control
/usr/local/pgsql-9.3/share/extension/postgis.control

I'm definitely using the expected version of Postgres, although I don't know it's actually the Kyngchaos version:

:~ anna$ psql --version
psql (PostgreSQL) 9.3.4

:~ anna$ which psql
/usr/local/pgsql-9.3/bin/psql

It looks like perhaps there are multiple versions of Postgres floating around on my system, and I'm using the wrong one?

:~ anna$ mdfind -name "postgres" | grep -G "postgres$"
/usr/local/pgsql-9.3/bin/postgres
/usr/local/var/postgres
/usr/local/Cellar/postgresql/9.3.4/bin/postgres

Can anyone advise me on what to do next?


FURTHER UPDATE

Here's the output of pg_config:

BINDIR = /usr/local/pgsql-9.3/bin
DOCDIR = /usr/local/pgsql-9.3/share/doc
INCLUDEDIR = /usr/local/pgsql-9.3/include
PKGINCLUDEDIR = /usr/local/pgsql-9.3/include
INCLUDEDIR-SERVER = /usr/local/pgsql-9.3/include/server
LIBDIR = /usr/local/pgsql-9.3/lib
PKGLIBDIR = /usr/local/pgsql-9.3/lib
LOCALEDIR =
MANDIR = /usr/local/pgsql-9.3/man
SHAREDIR = /usr/local/pgsql-9.3/share
SYSCONFDIR = /usr/local/pgsql-9.3/etc
PGXS = /usr/local/pgsql-9.3/lib/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--with-openssl' '--with-pam' '--with-krb5' '--with-gssapi' '--with-ldap' '--enable-thread-safety' '--with-bonjour' '--with-python' '--without-perl' '--enable-nls' '--with-libxml' 'CC=clang' 'CXX=clang++' 'CFLAGS=-Os -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk -D_FILE_OFFSET_BITS=64' 'LD=clang' 'LDLFAGS=-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.7.sdk'
CC = gcc
CPPFLAGS = -I/usr/include/libxml2
CFLAGS = -Os -arch x86_64 -D_FILE_OFFSET_BITS=64 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv
CFLAGS_SL =
LDFLAGS = -arch x86_64 -Wl,-dead_strip_dylibs
LDFLAGS_SL =
LIBS = -lintl -liconv -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -ledit -lz
VERSION = PostgreSQL 9.3.4

Best Answer

You need to also install postgis-scripts as included in the following, which solved the same issue for me: StackOverflow Answer

Related Question