Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to install earthdistance, an extension for Postgresql. The page for it says:

The earthdistance module provides two different approaches to calculating great circle distances on the surface of the Earth. The one described first depends on the cube package (which must be installed before earthdistance can be installed). The second one is based on the built-in point datatype, using longitude and latitude for the coordinates.

This seems to be true..

dealermade=# CREATE EXTENSION earthdistance FROM unpackaged;
ERROR:  required extension "cube" is not installed

However, I can't install cube either

dealermade=# CREATE EXTENSION cube FROM unpackaged;
ERROR:  type "cube" does not exist

Seems awkward the cube extension requires the cube type it provides. I'm using PostgreSQL 9.1.1. I'm doing this on Ubuntu, and I have companion package postgresql-contrib-9.1 installed. That said, there is no cube.sql on my system.

If I try to install earthdistance.sql directly I get this

$ psql -d db -f /usr/share/postgresql/9.1/extension/earthdistance--1.0.sql
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:31: ERROR:  type "cube" does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:49: ERROR:  type "earth" does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:55: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:61: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:67: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:73: ERROR:  type earth does not exist
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:79: ERROR:  could not access file "MODULE_PATHNAME": No such file or directory
psql:/usr/share/postgresql/9.1/extension/earthdistance--1.0.sql:88: ERROR:  function geo_distance(point, point) does not exist
share|improve this question
up vote 5 down vote accepted

FROM unpackaged is only for when it's already installed as a contrib module (i.e. from upgrading from 9.0) and you need to turn it into an extension. Therefore, just:

CREATE EXTENSION earthdistance;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.