Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Running a Ruby on Rails (RoR) app or Ruby code which uses the ActiveRecord framework, you get the error message:

Please install the postgresql adapter: gem install activerecord-postgresql-adapter

Trying to run:

gem install activerecord-postgresql-adapter

also fails, leaving you at a loss.

share|improve this question
You could read the following post to get an idea. – eKek0 Nov 2 '09 at 23:28
1  
what operating system? – eKek0 Nov 2 '09 at 23:29
My attempts at following that post are included in my original answer, as they did not work for me. – user71268 Nov 2 '09 at 23:32

7 Answers

The problem is not what anyone wrote. The problem is that the name of the postgresql database adapter is "postgresql", not "postgres", though the name of the GEM is "pg".

The definition in the database.yml file should include

  adapter: postgresql
share|improve this answer
This fixed my problem. Thanks! – localshred Aug 3 '10 at 21:15
This fixed my problem also!! – RyanWilcox Aug 2 '11 at 16:15
Yup, I did it too! – Jeff Dickey Nov 20 '11 at 7:59
1  
Is this something that could be fixed fairly easily? I mean so that the names are corrected and error messages appropriate? – delinquentme Feb 25 '12 at 3:16
Please install the postgres adapter: gem install activerecord-postgres-adapter – boulder_ruby Aug 31 '12 at 6:01

This means you don’t have the new ‘pg’ postgresql library installed. This is easily fixed with a bit of:

sudo gem install pg

I (Dov) found other solutions on the web which described setting GEM_HOME and adding ~/.gem/ruby/vers/bin to your PATH, but they didn't work. This solution above was provided by Mark Mansour on his blog State of Flux at: http://stateofflux.com/2008/7/13/activerecord-postgresql-adapter-in-rails-2-1/

share|improve this answer
4  
This one did not work for me ... still looking for a solution. – Toby Hede Nov 19 '09 at 6:00
I don't recommend installing gems with sudo. Better yet, use Bundler. – Steven Soroka Apr 17 at 22:20

Here's the answer I got from Heroku and it worked for me (after trying different pg gems, adapters, and everything else on the 10 other posts about this)

1) add the line: gem 'pg' to your Gemfile.

2) Run the command bundle install to install the gem into your bundle.

3) Stage the Gemfile and Gemfile.lock changes: git add Gemfile Gemfile.lock

4) Commit the changes: git commit -m "Install the pg gem"

5) Redeploy to heroku: git push heroku master

share|improve this answer

sudo apt-get install ruby1.8-dev

then...

gem install pg

Worked for me!

share|improve this answer
2  
What if we want to use 1.9.2? – Ramon Tayag Oct 28 '10 at 8:25

Check database.yml environment db is correct. If it is postgresql, you might need to change it to refer to mysql2 or whatever db your using for your given environment.

share|improve this answer

I did a little roundup of the current state of Ruby + PostgreSQL database drivers on railsonpostgresql.com; I think sudo gem install pg is probably the one you want.

share|improve this answer
Thank you. I was looking for the difference between different drivers. Information not as easy to find as I thought. – Nick Mar 17 '11 at 20:05

You can try this

On debian(squeeze):

aptitude install libdbd-pg-ruby
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.