Rails 1.2 isn't detecting the PostgreSQL 8.3 adapter (ruby-pg)

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.

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.

It's requring an older postgres gem that was just called postgres.

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

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.

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.

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.