Make bundler use different gems for different platforms
This is a known issue in Bundler. The workarounds are either:
- Generate a Gemfile.lock on a system similar enough to your production environment that you get results that match your production platform. Effectively, that means you can only generate the Gemfile.lock file on Windows if your production system is Windows.
- Don't commit a Gemfile.lock file at all, and determine dependencies on the production machine at deploy time (
bundle install
without--deploy
). While not recommended in general, this is an often-used workaround until the bug is fixed. For example, this is the recommended solution offered by Heroku. - Switch to JRuby, which would have the same platform string across both Windows and Linux (
java
). I don't recommend this seriously, but I believe it would fix the problem. - Fix the problem in the Bundler source code, i.e., help the Bundler team fix the bug. :)
I have a similiar problem. I would like to be able to write something like this in my Gemfile:
platforms :ruby do # linux
gem 'nokogiri', "1.5.0.beta.2"
end
platforms :mswin do
gem 'nokogiri', "1.4.4.1"
end
But, bundler tells me I am not allowed. So, my workaround, that works in this specific case is to point out a range of versions:
gem 'nokogiri', ">= 1.4.4.1", "<=1.5.0.beta.2"
Which - at the moment - give the 1.4.4.1 version on my Windows computer and 1.5.0.beta.2 on my linux computer. Maybe it is possible for you to write a similiar ugly workaround ;-)