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

Ruby

Ruby Problem Overview


I'm writing a gemspec for a new version of a gem that will now require Ruby 1.9. Previous versions of the gem were ok with Ruby 1.8, but now 1.9 will be required. Is there a way to cause the gem install for this version of the gem to fail with a warning for users who try to install it on Ruby 1.8?

Ruby Solutions


Solution 1 - Ruby

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'

Solution 2 - Ruby

gem.required_ruby_version = '1.9.2'

Should solve your problem :-)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondanView Question on Stackoverflow
Solution 1 - RubyrauschView Answer on Stackoverflow
Solution 2 - RubyTimon VonkView Answer on Stackoverflow