Nick Sieger: Gem clash: activerecord-jdbc-adapter and pgtag:blog.nicksieger.com,2005:TypoTypo2010-11-22T19:06:09+00:00Diego E. "Flameeyes" Pettenòurn:uuid:84d3ff02-1927-4191-bda7-721bffc7c4182010-01-29T04:09:24+00:002010-11-22T19:06:09+00:00Comment on Gem clash: activerecord-jdbc-adapter and pg by Diego E. "Flameeyes" Pettenò<p>Right now the gem has no platform (which is probably the same reason why Gentoo is packaging a broken activerecord-jdbc that installs for MRI, for a few more weks ;)) so that might explain it..</p>
<p>On the other hand, this is one thing that we won’t be hitting ourselves... I actually should remember to package this tomorrow night.</p>
<p>And by the way, I take the chance to tell you guys that hopefully after FOSDEM I might have pretty nice graphs to show about Gentoo’s support for JRuby: yesterday’s stats shows Ruby 1.9 and JRuby almost tied: 72 vs 70 packages... if headius can get me Duby, I’d have no problem to get the situation reserved, with more gems available for JRuby (now!) than for Ruby 1.9 (in a more distant future, as it’s not unmasked yet).</p>
<p>Of course, I cannot make Rails to be supported until I can clear racc... and that does not work on 1.4.0, so either I’ll have to wait for 1.5.0 RCs or skip over the tests for now..</p>Charlesurn:uuid:bef6a5df-436a-40ed-9036-549b297995c12010-01-29T01:33:32+00:002010-11-22T19:06:09+00:00Comment on Gem clash: activerecord-jdbc-adapter and pg by Charles<p>Can’t the gem platform stuff be used to guard against this? If that platform for the AR-JDBC gem is java, shouldn’t MRI ruby refuse to install it?</p>Nick Siegerurn:uuid:1500ad3a-6955-43fe-975a-3c663b48c1002010-01-28T15:16:49+00:002010-11-22T18:18:11+00:00Gem clash: activerecord-jdbc-adapter and pg<p>I got a note from a community member about an annoying problem that a <a href="http://blog.admoolabs.com/uninitialized-constant-activerecord-connectionadapters-postgresqladapter-pgconn/">few people have run into</a> when installing <code>activerecord-jdbc-adapter</code> (AR-JDBC) into a C Ruby implementation:</p>
<pre><code>NameError: uninitialized constant
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::PGconn
</code></pre>
<p>Turns out it’s pretty easy to momentarily forget to use <code>jruby -S gem</code> or <code>jgem</code> and just <code>gem install activerecord-jdbc-adapter</code> and suddenly your <code>pg</code> Postgres gems are not working properly. I thought it was worth documenting here in case others run into this problem.</p>
<p>I apologize for the clash. I had to provide a stub <code>pg.rb</code> in AR-JDBC inside of JRuby so that I could get <code>active_record/connection_adapters/postgresql_adapter.rb</code> to load with a database adapter type of <code>postgresql</code>. 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 <code>pg</code> library won’t work on JRuby anyway, right? Wrong.</p>
<p>I can think of a couple options going forward:</p>
<ol>
<li>Submit a patch to ActiveRecord so that <code>active_record/connection_adapters/postgresql_adapter.rb</code> can load without requiring <code>pg</code> up front and then AR-JDBC won’t have to stub it out.</li>
<li>Display a big fat warning message when AR-JDBC is installed into anything other than JRuby.</li>
</ol>
<p>Any other thoughts?</p>