How to Specify a Minimum Ruby Version in a Gemspec

How do you specify a minimum Ruby version in a gemspec?

From the RubyGems documentation:

# This gem will work with 1.8.6 or greater...
spec.required_ruby_version = '>= 1.8.6'

# Only with ruby 2.0.x
spec.required_ruby_version = '~> 2.0'

How do I know that a gem is compatible with a version of rails?

For rails 4 and 5 you can check here. If gem ready or not.

Rails automatically install best suited newest version of gem when you run bundle install if you write gem 'gemname'. Specifying a gem version is mention in other answers.

If a specific version of ruby or rails or any dependency is required in a gem. Then it is specified in gemspec file of gem and Gemfile for that gem.

You can cross-check in gemspec or Gemfile of gem also if something break while bundle install.

Can I install ruby gems for a specific ruby version?

The issue is not ActiveSupport, it's the Ruby version. What version of Ruby are you running? You should probably be using 2.0 or later.

Does Bundler Gem take in consideration your Ruby environment?

It depends! Bundler relies on the configuration of the Gemspecs that each Gem provides.

Gemspecs offer the posibility to provide different or additional dependencies based on the runtime environment. IE you can change the dependencies for JRuby or provide different binaries for i386 architectures.

As far as i know, it's not possible to declare a gem as 1.9 or 1.8 compatible (which would have made sense to me). I think it's partly so, because 1.9 is 99% downward compatible.

You are always forced to have a look at the gems themselves. Because of this, there are sites like http://isitruby19.com/

As you might see, it's not an issue of Bundler, but RubyGems.



Related Topics



Leave a reply



Submit