# 2.0.2 Postgres don't work

**URL:** <https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822>\
**Category:** Rails\
**Created:** [January 2, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822 "2008-01-02T21:54:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 2, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/1 "2008-01-02T21:54:24Z")

</div>

Hi,  
I got absutly no connection on Ubuntu LTS 6.06 AMD 64.

starting mongrel\_rails I got the error:

* * *

## snip

/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:231:in  
`establish_connection': Please install the postgres adapter:`gem  
install activerecord-postgres-adapter` (no such file to load –  
active\_record/connection\_adapters/postgres\_adapter)

* * *

## snap

Installed deb’s (db-related)

- libdbi-ruby1.8
- libpgsql-ruby1.8
- ruby1.8-dev

gems:

- postgres (0.7.9.2007.12.22)

Have anybody an idee?

PostgreSQL and rails 1.2.5 on an other Ubuntu LTS 6.06 machine worked  
very well.

require ‘postgres’ in irb is running.

Thanks in advance

Winkel

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 2, 2008, 10:14pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/2 "2008-01-02T22:14:21Z")

</div>

> `establish_connection': Please install the postgres adapter:`gem  
> install activerecord-postgres-adapter` (no such file to load –  
> active\_record/connection\_adapters/postgres\_adapter)

Did you do this?

gem install activerecord-postgres-adapter

?

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 2, 2008, 10:17pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/3 "2008-01-02T22:17:52Z")

</div>

> Did you do this?
> 
> gem install activerecord-postgres-adapter
> 
> ?  
> Yes indeed but it looks like as ‘activerecord-postgres-adapter’ is not a  
> gem.

I got the error:

## – ERROR: could not find activerecord-postgres-adapter locally or in a repository

Thanks

Winkel

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 3, 2008, 12:12am UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/4 "2008-01-03T00:12:09Z")

</div>

On Jan 2, 2008 3:54 PM, Carlos Grießmayer  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> `establish_connection': Please install the postgres adapter: `gem  
> install activerecord-postgres-adapter` (no such file to load –  
> active\_record/connection\_adapters/postgres\_adapter)

Do you have postgres or postgresql as the adapter name in your  
database.yml file?

The postgresql adapter (which is the proper name) is one of the  
remaining standard adapters stlll included with ActiveRecord-2.0.x

There is no gem.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 3, 2008, 1:42pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/5 "2008-01-03T13:42:09Z")

</div>

All I can think of is to ask Robby R., he usually keeps track of  
issues in Rails vs Postgresql:

[http://www.robbyonrails.com/](http://www.robbyonrails.com/)

f

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 3, 2008, 12:03am UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/6 "2008-01-03T00:03:23Z")

</div>

does script/plugin install activerecord-postgres-adapter work?

I looked on the [svn.rubyonrails.org](http://svn.rubyonrails.org) site and I couldn’t see the postgres  
adapter there. I tried installing it myself and I couldn’t find it  
either.

On Jan 3, 2008 7:47 AM, Carlos GrieÃŸmayer  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## I got the error:
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 3, 2008, 1:58pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/7 "2008-01-03T13:58:37Z")

</div>

I set up my current project under Rails 1.x and haven’t changed the  
database.yml for rails 2.0.2. Here’s an excerpt. It still works. I  
guess the older gems mentioned in the comments should still work, if  
you want to try them.

I’m using postgresql 8.2.5 on winxp. And another version on Linux.

# PostgreSQL versions 7.4 - 8.1

# 

# Get the C bindings:

# gem install postgres

# or use the pure-Ruby bindings on Windows:

# gem install postgres-pr

development:  
adapter: postgresql  
database: project\_development  
username: project  
password: whatever  
encoding: UTF8

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [January 3, 2008, 3:14pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/8 "2008-01-03T15:14:21Z")

</div>

On Jan 3, 2008 7:57 AM, fredistic [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> # Get the C bindings:
> 
> # gem install postgres
> 
> # or use the pure-Ruby bindings on Windows:
> 
> # gem install postgres-pr
> 
> development:  
> adapter: postgresql  
> database: project\_development  
> username: project  
> password: whatever  
> encoding: UTF8

I’m assuming that this was in response to my query about what the OP  
had in his database.yml.

To be clear about what I was suggesting:

Here’s his error:  
usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:231:in  
`establish_connection': Please install the postgres adapter: `gem  
install activerecord-postgres-adapter` (no such file to load –  
active\_record/connection\_adapters/postgres\_adapter)

Note that it’s asking for the postgres\_adapter NOT the  
postgreslq\_adapter. The postgres in that name is coming from the  
adapter specificed in database.yml.

The way ActiveRecord::Base works is like this.

1. It ensures that an adapter WAS in fact specified in the  
configuration (i.e. database.yml)

2. It sets up the gem environment

3. It then does this:

“active\_record/connection\_adapters/#{spec[:adapter]}\_adapter”  
rescue LoadError  
raise “Please install the #{spec[:adapter]} adapter:  
`gem install activerecord-#{spec[:adapter]}-adapter` (#{$!})”  
end

The gems are actually a fall back if the adapter isn’t a standard part  
of active-record. here are the relevant ‘built-in’ database adapters:

activerecord/connection\_adapters/mysql\_adapter.rb  
activerecord/connection\_adapters/postgresql\_adapter.rb  
activerecord/connection\_adapters/sqlite3\_adapter.rb  
activerecord/connection\_adapters/sqlite\_adapter.rb

So as I see it, I suspect that the OP has

adapter: postgres

instead of

adapter: postgresql

in his configuration

So it’s looking for a gem which has the fictitious postgres\_adapter.  
Note that these adapter gems are ActiveRecord connection adapters, not  
database gems which might be required for ruby support of the database  
in question.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [October 10, 2009, 7:23pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/9 "2009-10-10T19:23:30Z")

</div>

Do you have more than one gems directory.  
I had a similar problem and solved it via setting the GEN\_HOME variable  
to the personal gems install directory.

The problem…  
[~/rails/helloblog]# ./script/generate  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active\_record/connection\_adapters/abstract/connection\_specification.rb:76:in  
`establish_connection': Please install the postgresql adapter:`gem  
install activerecord-postgresql-…

The solution i found on net  
[~/rails/helloblog]# export GEM\_HOME=/home/phoad/ruby/gems  
[~/rails/helloblog]# export PATH=/home/phoad/ruby/bin:$PATH

Viola…  
[~/rails/helloblog]# ./script/generate scaffold Blog id:int title:string  
exists app/models/  
exists app/controllers/  
exists app/helpers/  
create app/views/blogs  
exists app/views/layouts/  
exists test/functional/

Good luck…

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [October 10, 2009, 7:38pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/10 "2009-10-10T19:38:27Z")

</div>

Moreover you may need to add --prefix parameter to your commands, like  
this.

[~/rails/helloblog]# rake db:migrate --prefix=$GEM\_HOME

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [March 9, 2011, 6:48am UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/11 "2011-03-09T06:48:51Z")

</div>

i am also same problem please give me solution . I am getting below  
error  
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connectio  
n\_adapters/abstract/connection\_specification.rb:76:in  
`establish_connection': Pl ease install the postgres adapter:`gem install  
activerecord-postgres-adapter` (  
no such file to load –  
active\_record/connection\_adapters/postgres\_adapter) (Run  
timeError)

## i am using

ruby 1.8.7  
rails 2.3.5  
pg 0.9.0

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [October 10, 2009, 8:19pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/12 "2009-10-10T20:19:46Z")

</div>

Philip H. wrote:

> > `establish_connection': Please install the postgres adapter: `gem  
> > install activerecord-postgres-adapter` (no such file to load –  
> > active\_record/connection\_adapters/postgres\_adapter)
> 
> Did you do this?
> 
> gem install activerecord-postgres-adapter
> 
> ?

The error message is misleading; there is no such gem. You’ll have to  
install or update the postgres or pg gem.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [March 9, 2011, 10:04pm UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/13 "2011-03-09T22:04:26Z")

</div>

On Mar 9, 12:25am, “Prasad B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## i am using
> 
> ruby 1.8.7  
> rails 2.3.5  
> pg 0.9.0

What’s your full list of gems installed? Back when I had problems  
like these it was because I had both the pg and another of the  
postgres drivers installed, although I can’t remember which exact one  
right now.

\Peter

---

<div class="post-metadata">

**Author:** ![winkel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/dbc845/32.png) [@winkel](https://www.ruby-forum.com/u/winkel)\
**Post date:** [March 9, 2011, 7:25am UTC](https://www.ruby-forum.com/t/2-0-2-postgres-dont-work/124822/14 "2011-03-09T07:25:29Z")

</div>

i am also same problem please give me solution . I am getting below  
error  
C:/Ruby187/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active\_record/connectio  
n\_adapters/abstract/connection\_specification.rb:76:in  
`establish_connection': Pl ease install the postgresql adapter:`gem install  
activerecord-postgresql-adapte  
r` (no such file to load – 1.8/pg\_ext) (RuntimeError)

## i am using

ruby 1.8.7  
rails 2.3.5  
pg 0.9.0

## in database.yml file:

development:  
adapter: postgresql  
host: localhost  
username: postgres  
password: root  
database: oilwell7\_development  
pool: 15  
encoding: utf8  
template: template0

But i have postgres\_adapter.rb file

C:\Ruby187\lib\ruby\gems\1.8\gems\activerecord-2.3.5\lib\active\_record\connection\_adapters  
but it says no such file to load .let me answer any one.

Thansk in advance
