Forum: Ruby on Rails Rails 1.2 isn't detecting the PostgreSQL 8.3 adapter (ruby-pg)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ed3050ec0a96c03ef1304e7ad1ff46fb?d=identicon&s=25 The Neurochild (Guest)
on 2008-10-27 19:08
(Received via mailing list)
Hi everyone.

When I run the rake db:migrate instruction, I get the following error
(with --trace):

(in /home/jescajadillo/aptana/workspace/amazing)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
no such file to load -- postgres
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`gem_original_require'
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:495:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:342:in `new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/dependencies.rb:495:in `require'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/core_ext/kernel/requires.rb:7:in
`require_library_or_gem'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/
active_support/core_ext/kernel/requires.rb:5:in
`require_library_or_gem'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/connection_adapters/postgresql_adapter.rb:7:in
`postgresql_connection'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
262:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
262:in `connection_without_query_cache='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/query_cache.rb:54:in `connection='
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
230:in `retrieve_connection'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
78:in `connection'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/
active_record/migration.rb:284:in `migrate'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/tasks/databases.rake:
4
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:621:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:621:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:616:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:616:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:582:in
`invoke_with_call_chain'
/usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:575:in
`invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:568:in
`invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2031:in
`invoke_task'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2009:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2009:in
`each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2009:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2048:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2003:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:1982:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:2048:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake.rb:1979:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.2/bin/rake:31
/usr/local/bin/rake:19:in `load'
/usr/local/bin/rake:19

This is weird because I have the ruby-pg gem and I have no problem
with Rails 2.1. I get this error with the previous version of Rails,
1.2. It's not working here. What's going on?

My project has PostgreSQL 8.3 database and I want to make it work. Can
you please help me?

Later...

The Neurochild.
4375b4aca04b8d72482fd409fb6d0b47?d=identicon&s=25 Roderick van Domburg (roderickvd)
on 2008-10-27 19:24
Hi Neurochild,

> This is weird because I have the ruby-pg gem and I have no problem
> with Rails 2.1. I get this error with the previous version of Rails,
> 1.2. It's not working here. What's going on?

Rails 1.2 doesn't support the newer ruby-pg gem. Use the postgres gem
instead.

--
Roderick van Domburg
http://www.nedforce.nl
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-27 19:44
(Received via mailing list)
It's requring an older postgres gem that was just called postgres.

Sent from my iPhone
Ed3050ec0a96c03ef1304e7ad1ff46fb?d=identicon&s=25 The Neurochild (Guest)
on 2008-10-27 19:49
(Received via mailing list)
Yeah, right! I discovered shortly after installing the postgres gem.
(I downloaded the one from the ruby-pg project website which has
PostgreSQL 8.3 support). The migration worked perfectly.

I believe I'll stop updating software. XD

Thank you guys.

The Neurochild
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-10-27 21:45
With Rails 2.1.1 I have the same problem, it can't find it with
config.gem, however connection to the DB when the gem is installed works
perfectly.
4375b4aca04b8d72482fd409fb6d0b47?d=identicon&s=25 Roderick van Domburg (roderickvd)
on 2008-10-27 23:12
Hi Fernando,

> With Rails 2.1.1 I have the same problem, it can't find it with
> config.gem, however connection to the DB when the gem is installed works
> perfectly.

Have you also tried the "pg" gem? I believe that's the preferred way of
installing the gem from the ruby-pg project. (Yeah, it's confusing.) pg
is at version 0.7.9.2008.10.13 and ruby-pg is at 0.7.9.2008.01.28.

If that fails, ensure that you've got the latest version of RubyGems. I
believe 1.3.0 is where it's at. Finally, check the file permissions on
the gem directory. Everything contained therein should generally be
world-readable and the .so files should be world-executable too.

--
Roderick van Domburg
http://www.nedforce.nl
059ed46172a087063ce26250e44c8627?d=identicon&s=25 Fernando Perez (fernando)
on 2008-10-28 14:21
You are right! There is something wrong with the gems and their
versions.

From the official website: http://rubyforge.org/projects/ruby-pg/

I see:

ruby-pg -> ruby-pg-0.7.9.2008.10.13    October 14, 2008
ruby-postgres -> postgres-0.7.9.2008.01.28    January 28, 2008

Therefore I installed the gem ruby-pg, but look at my "gem list" output:

ruby-pg (0.7.9.2008.01.28)

This is wrong!


Installing "sudo gem install pg" fixed the version problem, and now
Rails 2.1.2 can detect the gem with gem.config

Everything works 100% perfectly.
This topic is locked and can not be replied to.