0

I am running "heroku run rake db:migrate" after I have deployed my app to heroku and I get this:

$>>heroku run rake db:migrate

Running rake db:migrate attached to terminal... up, run.1
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)

I try installing the gem mentioned but nothing happens. I am using rails3 an ruby 1.9.3, and my database.yml file contains:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

How can I fix this error?

EDIT:

running $>>sudo gem install pg -v '0.13.2'

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.8 extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/ruby1.8
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/pg-0.13.2 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/pg-0.13.2/ext/gem_make.out

I am getting this error. Again I am using 1.9.3 version of ruby.

Test Test
  • 2,831
  • 8
  • 44
  • 64

2 Answers2

1

Your database.yml is setup to use sqlite3.

If you want to use postgresql you need to install postgres on your computer first.

For Linux:

sudo apt-get install postgresql

For Max OS X:

brew install postgresql

Make you have homebrew installed first.

heroku autogenerates database.yml on the deploy. Reads like: it doesn't matter what you put in your database.yml, which to me is nice, as I can include it in git without worrying about production db passwords.

Then install the pg gem by putting this in your Gemfile:

gem 'pg', :require => 'pg'

if you are using an older version of Rails use the gem install method.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Eric Sites
  • 1,494
  • 10
  • 16
  • Eric, Heroku always uses Postgres, no matter what you put in `database.yml`. But unless you are rolling your own SQL, there is no harm in running SQLite locally and Postgres on Heroku. The OP's original problem was related to Heroku deployment; now he is running into another problem installing Postgres locally, which is different from what the original question was about. – Alex D Mar 13 '12 at 19:57
  • Hey I found a working solution here: http://stackoverflow.com/questions/6040583/unable-to-install-pg-gem-on-ubuntu – Test Test Mar 13 '12 at 20:04
0

Try adding the 'pg' gem to your Gemfile (and then bundle install).

Alex D
  • 29,755
  • 7
  • 80
  • 126
  • how do I configure it to use postgersql? – Test Test Mar 13 '12 at 19:45
  • @EricSites, Heroku always uses Postgres, no matter what you put in `database.yml`. – Alex D Mar 13 '12 at 19:55
  • @TestTest, if you just want to get your app working as quickly as possible, you can always `bundle install` *on a machine which has a working install of Postgres*. It's better to have it running on your development machine too, but that is a different problem from what you originally asked for help with. OR, you can hack `Gemfile.lock` by hand -- I've done this before when developing on Windows and deploying to Heroku, because some gems I needed to use couldn't be installed on Windows. – Alex D Mar 13 '12 at 20:01