# Postgres adapter issues with Rails 2.1: ruby-pg is the answer!

**URL:** <https://www.ruby-forum.com/t/postgres-adapter-issues-with-rails-2-1-ruby-pg-is-the-answer/148554>\
**Category:** Rails\
**Created:** [September 14, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/postgres-adapter-issues-with-rails-2-1-ruby-pg-is-the-answer/148554 "2008-09-14T22:27:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skaufman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@skaufman](https://www.ruby-forum.com/u/skaufman)\
**Post date:** [September 14, 2008, 10:27pm UTC](https://www.ruby-forum.com/t/postgres-adapter-issues-with-rails-2-1-ruby-pg-is-the-answer/148554/1 "2008-09-14T22:27:32Z")

</div>

While upgrading Rails 2.0.2 sites to Rails 2.1.1, I encountered a  
weird postgres adapter problem. Although the old postgresql adapter  
(aka ruby-postgres) works fine with Rails 2.1.1 on my Mac dev box  
(running PG 8.2.6) and also works fine with Rails 2.0.2 apps on a  
Debian etch staging server (running PG 8.2.1), this error occurs when  
trying to cap deploy 2.1.1 apps on the Debian box: “PQserverVersion  
not supported by this client version”. This error occurs at the point  
of the rake migration task.

This error has everything to do with the change from Rails 2.0.2 to  
2.1.1; by changing the version of Rails back to 2.0.2 in config/  
environment.rb, the rake migration proceeds fine and the PG db  
connects fine in script/console. This problem is most mysterious, as  
it didn’t manifest itself on my Mac (the only difference that I can  
easily see is the slightly newer PG version).

However, the solution turns out to be easy: simply use the ruby-pg  
adapger ([https://rubyforge.org/projects/ruby-pg/](https://rubyforge.org/projects/ruby-pg/)). The omnipresent  
Fred C had suggested that this adapter might not work on pre-2.1 apps  
([Ruby-postgres gem installation on Leopard - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/156143)), but it appears to work just  
fine here.

Furthermore, the ruby-pg adapter project is in the reliable hands of  
Jeff D., a superstar whose abilities mean that PG has a brilliant  
future with Rails. Hurrah for that!

Anyway, I hope that this saves someone else some time.

---

<div class="post-metadata">

**Author:** ![skaufman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@skaufman](https://www.ruby-forum.com/u/skaufman)\
**Post date:** [September 15, 2008, 8:22am UTC](https://www.ruby-forum.com/t/postgres-adapter-issues-with-rails-2-1-ruby-pg-is-the-answer/148554/2 "2008-09-15T08:22:44Z")

</div>

On Sep 14, 10:26 pm, Stan K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 2.1.1; by changing the version of Rails back to 2.0.2 in config/
> 
> Furthermore, the ruby-pg adapter project is in the reliable hands of  
> Jeff D., a superstar whose abilities mean that PG has a brilliant  
> future with Rails. Hurrah for that!
> 
> Anyway, I hope that this saves someone else some time.

In Rails edge, ruby-pg is mandatory. ruby-postgres doesn’t work.

A report is send in lighthouse :  
[http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/996-nomethoderror-undefined-method-transaction\_status-for-pgconn0xb719eb0c#ticket-996-3](http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/996-nomethoderror-undefined-method-transaction_status-for-pgconn0xb719eb0c#ticket-996-3)

–  
Cyril M.  
[http://blog.shingara.fr/en](http://blog.shingara.fr/en)

---

<div class="post-metadata">

**Author:** ![skaufman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@skaufman](https://www.ruby-forum.com/u/skaufman)\
**Post date:** [October 19, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/postgres-adapter-issues-with-rails-2-1-ruby-pg-is-the-answer/148554/3 "2008-10-19T18:40:25Z")

</div>

On my Debian Etch box I have installed PostgreSQL from backports repo.

## When I want to install ruby-pg with “gem1.8 install ruby-pg”, I get the following error:

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

## /usr/bin/ruby1.8 extconf.rb install ruby-pg extconf.rb:1: command not found: pg\_config --includedir extconf.rb:52: command not found: pg\_config --libdir checking for main() in -lpq… no \*\*\* 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.

What additional options should I pass in order to compile the ruby-pg  
gem?

---

<div class="post-metadata">

**Author:** ![skaufman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8e7dd6/32.png) [@skaufman](https://www.ruby-forum.com/u/skaufman)\
**Post date:** [October 20, 2008, 1:09am UTC](https://www.ruby-forum.com/t/postgres-adapter-issues-with-rails-2-1-ruby-pg-is-the-answer/148554/4 "2008-10-20T01:09:12Z")

</div>

> –  
> Building native extensions. This could take a while…  
> ERROR: Error installing ruby-pg:  
> ERROR: Failed to build gem native extension.

I had the same problem.

I have some additional questions.

Why is the “official” postgres gem for rails ruby-pr when it doesn’t  
work on windows at all and doesn’t install on linux out of the box?

What happened to postgres-pr?

Why are there so many gems for postgres and why are so many of them  
abandoned?

Is postgres a second class citizen in rails?
