0

I'm using postgres (PostgreSQL) 9.3.5 with my Rails (4.0.1) app and Ruby (2.0.0-p451), and one of the migrations looks like:

class CreateExtensions< ActiveRecord::Migration
    def up
        connection = ActiveRecord::Base.connection
        extensions = %w(fuzzystrmatch hstore plpgsql postgis postgis_tiger_geocoder postgis_topology)
        ext_query = extensions.map {|e| "CREATE EXTENSION IF NOT EXISTS #{e};" }.join
        connection.execute(ext_query)
    end
end

Whenever I try to run the migration file I get the following error:

CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;CREATE EXTENSION IF NOT EXISTS hstore;CREATE EXTENSION IF NOT EXISTS plpgsql;CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;CREATE EXTENSION IF NOT EXISTS postgis_topology;
PG::UndefinedFile: 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
: CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;CREATE EXTENSION IF NOT EXISTS hstore;CREATE EXTENSION IF NOT EXISTS plpgsql;CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;CREATE EXTENSION IF NOT EXISTS postgis_topology;
ActiveRecord::StatementInvalid: PG::UndefinedFile: 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
: CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;CREATE EXTENSION IF NOT EXISTS hstore;CREATE EXTENSION IF NOT EXISTS plpgsql;CREATE EXTENSION IF NOT EXISTS postgis;CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;CREATE EXTENSION IF NOT EXISTS postgis_topology;
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `async_exec'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:435:in `block in log'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activesupport-4.0.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:430:in `log'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
    from (irb):14
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
    from /Users/info/.rvm/gems/ruby-2.0.0-p451/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

I installed Postgres using Homebrew, Any idea what am I doing wrong here?

5
  • 3
    Did you install PostGIS? Commented Oct 7, 2014 at 11:41
  • yes I did using homebrew and I have postgis-2.1.4_1 already installed. Commented Oct 7, 2014 at 12:49
  • @NickVeys, do I need to install a different version? Thanks for your willing to help Commented Oct 7, 2014 at 12:53
  • 3
    You installed PostGIS via Homebrew and you had it already installed? Everything I've seen on this error indicates PostGIS is not properly installed. Nothing to do with Rails or Ruby. Commented Oct 7, 2014 at 13:26
  • You are right @NickVeys, once I removed PostGIS and reinstalled it through Homebrew it worked. Please post your comment as an answer so I can accept it. Many thanks Commented Oct 7, 2014 at 14:22

1 Answer 1

1

Make sure you have PostgreSQL and PostGIS installed from the same sources and with compatible versions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.