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


#1

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:inrequire’
/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:innew_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:inrequire_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:inrequire_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:insend’
/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:inconnection=’
/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:inconnection’
/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:incall’
/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:ineach’
/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:ininvoke_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:ininvoke_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:ininvoke_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:ineach’
/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:instandard_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:inrun’
/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:inrun’
/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 N…


#2

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


#3

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

Sent from my iPhone


#4

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.


#5

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 N.


#6

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.


#7

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