Gem clash: activerecord-jdbc-adapter and pg
Posted by Nick Sieger Thu, 28 Jan 2010 15:16:49 GMT
I got a note from a community member about an annoying problem that a few people have run into when installing activerecord-jdbc-adapter
(AR-JDBC) into a C Ruby implementation:
NameError: uninitialized constant
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn
Turns out it’s pretty easy to momentarily forget to use jruby -S gem
or jgem
and just gem install activerecord-jdbc-adapter
and suddenly your pg
Postgres gems are not working properly. I thought it was worth documenting here in case others run into this problem.
I apologize for the clash. I had to provide a stub pg.rb
in AR-JDBC inside of JRuby so that I could get active_record/connection_adapters/postgresql_adapter.rb
to load with a database adapter type of postgresql
. Because of load path order issues, I couldn’t get AR-JDBC’s code to load before ActiveRecord’s. At the time I was thinking this wouldn’t be a problem because the pg
library won’t work on JRuby anyway, right? Wrong.
I can think of a couple options going forward:
- Submit a patch to ActiveRecord so that
active_record/connection_adapters/postgresql_adapter.rb
can load without requiringpg
up front and then AR-JDBC won’t have to stub it out. - Display a big fat warning message when AR-JDBC is installed into anything other than JRuby.
Any other thoughts?