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)
Almost seems like running 'gem install' adds it to the global available gems (and hence terminal can run the package's commands), whereas adding it to the gemfile and running bundle install only adds it to the application. Similar to npm install --global. that's basically it.
Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed. Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install .
Platforms are essentially identical to groups, except that you do not need to use the --without install-time flag to exclude groups of gems for other platforms. There are a number of Gemfile platforms: ruby. C Ruby (MRI), Rubinius, or TruffleRuby, but not Windows.
Show activity on this post. I know that when using gem install , the gem will be stored under /home/username/. rvm/gems/, under which gemset the gem was installed.
You don't need 2 different Gemfiles in order to achieve platform-specific gem-requirements. Just check for the RUBY_VERSION and put your gems in some sort of conditional clause:
if(defined?(JRUBY_VERSION))
gem 'warbler'
else
case(RUBY_VERSION)
when('1.8.7')
gem 'ruby-debug'
when('1.9.2')
gem 'ruby-debug19'
when('1.9.3')
gem 'debugger'
end
end
That should do the trick.
With best regards,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With