rubybundler

Working with bundler and different platform gem requirements


I seem to struggling with what I thought was standard functionality of bundler, according the manual The ability to specifiy that gems should be required on for certain platforms using the :platforms option or platforms block

I want to specifcy a different version of a gem dependent on the version of ruby used

source "http://rubygems.org"
gem "trollop", "~> 1.16.2"
gem "chronic", "~> 0.6.4"
gem "highline", "~> 1.6.2"
gem "colorize", "~> 0.5.8"
gem "queryparams", "~> 0.0.3"

platforms :ruby_18 do
  gem "json"
  gem "activesupport", "~>2.8.9"
end

platforms :ruby_19 do
  gem "activesupport", "~>3.1.3"
end

However this fails when running bundle install

You cannot specify the same gem twice with different version requirements.
You specified: activesupport (~> 2.8.9) and activesupport (~> 3.1.3)

Solution

  • I'm pretty sure this is not doable. A gemfile cannot have the same gem specified with different versions. Not only within different platforms but even not in different groups (group_ruby_18, group_ruby_19) and then by trying bundle install --without group_ruby_18

    So this will fail too.

    I had this problem before and the only solution I found was to have 2 different GEMFILES.