Need help with adding gem 'postgresql'


#1

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


#2

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


#3

Ran into the same issue today. Found this googling: https://stackoverflow.com/questions/48225233/gemloaderror-cant-activate-pg-0-18-already-activated-pg-1-0-0

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

Change:
gem 'pg'
To:
gem 'pg', '~> 0.18'


#4

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


#5

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