Trying to use PostGIS with Postgres: "ERROR: could not open extension control file"
Searching a bit around I found this GIST where user jordanmkoncz gives a solution for OSX:
- Use homebrew to install PostGIS.
- You need to be careful because brew will install the latest available version of PostGIS which may not be compatible with your specific version of PostgreSQL. Here is a compatibility table for your convenience.
To install a specific version of PostGIS (or any other formula) jordnmkoncz recommends using this method: Homebrew install specific version of formula? for installing spec
I had the same problem with Linux Mint (Ubuntu like) which I solve following this gis.stackexchange thread.
Richard
Updated on June 24, 2022Comments
-
Richard almost 2 years
I've just installed Postgres 9.3.4 and PostGIS 2.1 on OSX Mavericks using the very latest versions of the KyngChaos libraries.
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 if this is where the KyngChaos libraries usually install to:
Annas-MacBook-Air:~ anna$ psql --version psql (PostgreSQL) 9.3.4 Annas-MacBook-Air:~ anna$ which psql /usr/local/pgsql-9.3/bin/psql
I've been quite careful not to install Postgres using Homebrew etc because I know that it can cause problems having multiple versions of the same system.
Can anyone advise on why the extension file isn't in the expected place?
UPDATE:
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
Which one should I be using, and how can I set the system to use this one by default?
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