codeforamerica/citygram

Migration Error with setting up Citygram and Boxen

Closed this issue · 4 comments

Attempting to setup citygram with a Boxen setup. The DB is successully created, but migrations fail with the following error.

 bundle exec rake db:migrate DATABASE_URL=postgres://localhost:15432/citygram_development
rake aborted!
Sequel::DatabaseError: PG::UndefinedFile: ERROR:  could not open extension control file "/opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/extension/postgis.control": No such file or directory
/Users/masonpackard/src/citygram/db/migrations/001_enable_postgis_extension.rb:3:in `block (2 levels) in <top (required)>'
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
PG::UndefinedFile: ERROR:  could not open extension control file "/opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/extension/postgis.control": No such file or directory
/Users/masonpackard/src/citygram/db/migrations/001_enable_postgis_extension.rb:3:in `block (2 levels) in <top (required)>'
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

From this gist can you try these recommended commands, then retry your migration?

brew install geos proj gdal libxml2 json-c
brew reinstall postgis --build-from-source

Just ran those two commands. Here is the following error:

undle exec rake db:migrate DATABASE_URL=postgres://localhost:15432/citygram_development
rake aborted!
Sequel::DatabaseError: PG::UndefinedFile: ERROR:  could not open extension control file "/opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/extension/postgis.control": No such file or directory
/Users/masonpackard/src/citygram/db/migrations/001_enable_postgis_extension.rb:3:in `block (2 levels) in <top (required)>'
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
PG::UndefinedFile: ERROR:  could not open extension control file "/opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/extension/postgis.control": No such file or directory
/Users/masonpackard/src/citygram/db/migrations/001_enable_postgis_extension.rb:3:in `block (2 levels) in <top (required)>'
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
 ✘  ~/src/citygram   master  

Here is the output from running those two commands:

brew install geos proj gdal libxml2 json-c
Warning: geos-3.4.2 already installed
Warning: proj-4.9.1 already installed
Warning: gdal-1.11.2_1 already installed
Warning: libxml2-2.9.2 already installed
Warning: json-c-0.12 already installed
 ~/src/citygram   master  brew reinstall postgis --build-from-source
==> Reinstalling postgis
==> Installing dependencies for postgis: autoconf, automake, libtool
==> Installing postgis dependency: autoconf
==> Downloading http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/autoconf/2.69
==> make install
🍺  /opt/boxen/homebrew/Cellar/autoconf/2.69: 70 files, 3.1M, built in 9 seconds
==> Installing postgis dependency: automake
==> Downloading http://ftpmirror.gnu.org/automake/automake-1.15.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/automake/1.15
==> make install
🍺  /opt/boxen/homebrew/Cellar/automake/1.15: 130 files, 3.2M, built in 8 seconds
==> Installing postgis dependency: libtool
==> Downloading http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/opt/boxen/homebrew/Cellar/libtool/2.4.6 --program-prefix=g --enable-ltdl-install
==> make install
==> Caveats
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==> Summary
🍺  /opt/boxen/homebrew/Cellar/libtool/2.4.6: 69 files, 3.8M, built in 16 seconds
==> Installing postgis
==> Downloading http://download.osgeo.org/postgis/source/postgis-2.1.7.tar.gz
Already downloaded: /opt/boxen/cache/homebrew/postgis-2.1.7.tar.gz
==> ./configure --with-projdir=/opt/boxen/homebrew --with-jsondir=/opt/boxen/homebrew/opt/json-c --with-pgconfig=/opt/boxen/homebrew/Cellar/postgresql
==> make
==> make install DESTDIR=/private/tmp/postgis20150707-6071-1m2qddp/postgis-2.1.7/stage
==> Caveats
To create a spatially-enabled database, see the documentation:
  http://postgis.net/docs/manual-2.1/postgis_installation.html#create_new_db_extensions
If you are currently using PostGIS 2.0+, you can go the soft upgrade path:
  ALTER EXTENSION postgis UPDATE TO "2.1.5";
Users of 1.5 and below will need to go the hard-upgrade path, see here:
  http://postgis.net/docs/manual-2.1/postgis_installation.html#upgrading

PostGIS SQL scripts installed to:
  /opt/boxen/homebrew/share/postgis
PostGIS plugin libraries installed to:
  /opt/boxen/homebrew/opt/postgresql/lib
PostGIS extension modules installed to:
  /opt/boxen/homebrew/opt/postgresql/share/postgresql/extension
==> Summary
🍺  /opt/boxen/homebrew/Cellar/postgis/2.1.7_1: 45 files, 8.3M, built in 46 seconds
 ~/src/citygram   master  bundle exec rake db:migrate DATABASE_URL=postgres://localhost:15432/citygram_development
rake aborted!
Sequel::DatabaseError: PG::UndefinedFile: ERROR:  could not open extension control file "/opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/extension/postgis.control": No such file or directory
/Users/masonpackard/src/citygram/db/migrations/001_enable_postgis_extension.rb:3:in `block (2 levels) in <top (required)>'
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
PG::UndefinedFile: ERROR:  could not open extension control file "/opt/boxen/homebrew/Cellar/postgresql/9.3.2-boxen/share/postgresql/extension/postgis.control": No such file or directory
/Users/masonpackard/src/citygram/db/migrations/001_enable_postgis_extension.rb:3:in `block (2 levels) in <top (required)>'
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
 ✘  ~/src/citygram   master  rake db:migrate
rake aborted!
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.3.2. Prepending `bundle exec` to your command may solve this.
/Users/masonpackard/src/citygram/Rakefile:2:in `<top (required)>'
(See full trace by running task with --trace)
 ✘  ~/src/citygram   master  bundle exec rake db:migrate
rake aborted!
Sequel::DatabaseConnectionError: PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
PG::ConnectionBad: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
/Users/masonpackard/src/citygram/lib/database_helper.rb:60:in `migrate_db'
/Users/masonpackard/src/citygram/lib/tasks/database.rake:26:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Mason is a coworker of mine. The issue here turned out to be that the "brew install" stanza I recommended installed a 9.4 flavor of postgres, when his machine was still trying to run 9.3 in some ways. The first part of the gist worked for setting it up.