PostgreSQL Installation – Fix CREATE EXTENSION File Not Found Error on Mac OS

installationmac os xpostgresqlpostgresql-extensions

On PostgreSQL 9.2.3 when trying this:

CREATE EXTENSION btree_gist;

I get this error:

ERROR: could not open extension control file "/opt/local/share/postgresql92/extension/btree_gist.control": No such file or directory

Running SELECT pg_available_extensions(); shows that indeed is not available.

Best Answer

The problem is that the needed contrib files are not installed. This was actually the case for several contrib modules.

I found help with the solution to this here:
https://wiki-bsse.ethz.ch/display/ITDOC/Get+PostgreSQL+contrib+modules+on+Mac+OS+X

$ su
# port build postgresql92
# cd `port work postgresql92`/postgresql-<version>/contrib
# for d in *; do test -d $d && ( echo $d; cd $d; make all && make install; cd .. ); done

I suspect reinstalling everything would work too, but this highlights the actual problem.