1

I'm trying to do a heroku db:migrate with my mySQL database and I'm getting the error/suggestion:

Please install the postgresql adapter: gem install activerecord-postgresql-adapter (pg is not part of the bundle. Add it to Gemfile.)

I try to put the "gem install activerecord-postgresql-adapter" in my gem-file, but when I run bundle install, I get:

charlotte-dator:showwwdown holgersindbaek$ bundle install /Users/holgersindbaek/Projekter/Showwwdown/showwwdown/Gemfile:34:in evaluate': undefined local variable or methodactiverecord' for # (NameError) from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/definition.rb:17:in build' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler.rb:138:indefinition' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/cli.rb:219:in install' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:insend' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/task.rb:22:in run' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/invocation.rb:118:ininvoke_task' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor.rb:263:in dispatch' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/lib/bundler/vendor/thor/base.rb:386:instart' from /Library/Ruby/Gems/1.8/gems/bundler-1.0.21/bin/bundle:13 from /usr/bin/bundle:19:in `load' from /usr/bin/bundle:19

Hope you can help. Thanks!

Holger Sindbaek
  • 2,278
  • 6
  • 41
  • 68
  • possible duplicate of http://stackoverflow.com/questions/7822896/rails-and-postgres-pg-gem-ignored-during-deploy-on-heroku – John Beynon Oct 20 '11 at 16:00
  • Thank you. There seemed to be some help there. After I added gem 'pg' to my gemfile and ran bundle install, I forgot to commit and push to heroku – Holger Sindbaek Oct 20 '11 at 16:13

2 Answers2

1

Add the following line to your gemfile (instead):

gem 'pg'

If you don't use Postgres in development, you can do this:

gem 'pg', :group => :production
coreyward
  • 77,547
  • 20
  • 137
  • 166
  • I'm using mySQL in development and even though i put "gem 'pg', :group => :production" in the gem-file, i still get: "rake aborted! Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)" – Holger Sindbaek Oct 20 '11 at 15:37
  • You must also re-bundle after making any changes to your `Gemfile`. You re-bundle by running the command `bundle`. After you re-bundle, add the `Gemfile.lock` to git and re-deploy to Heroku. – yfeldblum Oct 20 '11 at 15:49
  • it's giving me the same error when running bundle, instead of bundle install. – Holger Sindbaek Oct 20 '11 at 15:54
  • Sorry.. didn't understand you at first. I should commit and push the files to heroku and then run db:migrate. Found the help in: http://stackoverflow.com/questions/7822896/rails-and-postgres-pg-gem-ignored-during-deploy-on-heroku – Holger Sindbaek Oct 20 '11 at 16:12
  • `bundle` is the same as `bundle install`. You should always run `bundle` or `bundle update [gemname]` after updating your Gemfile. If you want Heroku to have the changes you make to your Gemfile, yes, you need to commit and push them. – coreyward Oct 20 '11 at 16:29
1

Make sure the branch you are pushing to heroku is master branch.

In my case i had tried all above & it was not working. I had done another mistake when i pushed my git repository i didn't push master branch but instead another 'named' branch. So my changes were not getting reflected even after updating gem file etc .

Aman
  • 916
  • 11
  • 16