At Bloom, we’re looking into using JRuby instead of MRI. To support the two implementations, some gems are different. Case in point: RMagick and the JSON gems:

config/environment.rb
 1 # More config.gem declarations elided
 2 
 3 if defined?(JRUBY_VERSION) then
 4   config.gem "activerecord-jdbc-adapter", :version => "0.9.2",  :lib => "jdbc_adapter"
 5   config.gem "json-jruby",  :version => "1.2.0",  :lib => "json"
 6   config.gem "rmagick4j",   :version => "0.3.6",  :lib => "RMagick"
 7 else
 8   config.gem "json",        :version => "1.2.0"
 9   config.gem "rmagick",     :version => "2.12.2", :lib => "RMagick"
10 end

I created the following in Gemfile:

Gemfile
 1 source :gemcutter
 2 
 3 gem "rails", "= 2.3.4"
 4 gem "pg", "~> 0.8.0" if !defined?(JRUBY_VERSION)
 5 
 6 if defined?(JRUBY_VERSION) then
 7   gem "activerecord-jdbc-adapter", ">= 0.9.2",  :lib => "jdbc_adapter"
 8   gem "json-jruby", ">= 1.2.0"
 9   gem "rmagick4j", ">= 0.3.6"
10 else
11   gem "json", ">= 1.2.0"
12   gem "rmagick", ">= 2.12.2"
13 end
14 
15 # Ruby's 1.9 stdlib replaced CSV with the implementation of 1.8's FasterCSV, but
16 # the upgrade path is problematic: we have to change how we're loading the library.
17 gem "fastercsv" if RUBY_VERSION =~ /^1\.8/

Notice I target 3 versions of Ruby: MRI 1.8, MRI 1.9 and JRuby. If I bundle lock from one Ruby implementation, then the other ones won’t be able to use the locked bundle:

 1 [jruby-1.4.0]$ bundle unlock && bundle lock
 2 The bundle is now unlocked. The dependencies may be changed.
 3 The bundle is now locked. Use `bundle show` to list the gems in the environment.
 4 
 5 [jruby-1.4.0]$ rvm use 1.8.7
 6 Now using ruby 1.8.7 p248
 7 
 8 [ruby-1.8.7-p248]$ bundle check
 9 Could not find gem 'rmagick4j (= 0.3.7, runtime)' in any of the sources.

I’m using Bundler in the context of a Rails 2.3.4 application, but we’ll eventually move to Rails 3. Anybody has any experience using Bundler in this way?

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails coder. During the day, I work on AdGear, an ad distribution platform for publishers. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on