Need help with adding gem 'postgresql'


I’m on one of the last steps in Installfest.

After I enter:
heroku run rails db:migrate

I get:
rails aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add 'gem 'pg' to your Gemfile (and ensure its versions are at the minimum required by ActiveRecord)

And then a bunch of rows that look like : /app/vendor/bundle/ruby

I’ve redone earlier steps such as:
gem install bundler

I’ve also searched for the gem to make sure I have it:
gem search ^postgresql

the result:
postgresql (1.0.0)
postgresql-check (0.1.3) and about 3 more below it.

The last thing I have tried is (numerous times much earlier before getting help as well):
gem install postgresql

The result:
ERROR: Error installing postgresql:
ERROR: Failed to build gem native extension

No clue what to do. Sorry if I wasn’t clear :frowning:

Quick EDIT: I have tried sudo apt-get install postgresql


Hey @WascallyWabbyte can you post the contents of your Gemfile.rb please?


Ran into the same issue today. Found this googling:

Apparently pg 1.0 is not compatible with rails 5.1.4 so you need to change the pg version in the gemfile.

gem 'pg'
gem 'pg', '~> 0.18'


Hey all, this may be what you’re all looking for.
Follow the instructions and report back if this solves your problem!


One million likes–solved my problem and my sanity. Thanks!