Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ruby

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?

like image 733
dan Avatar asked Feb 15 '11 13:02

dan


People also ask

How do I install a specific version of a ruby gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.

What is Gemspec in Gemfile?

So It all started in 2006 when RubyGems created Gemspec to define Ruby package specifications. Gemspec is basically the Readme for gems. It tells you about the author, version, summary, description, internal dependencies, execution and everything about the Gem.

How do I check RubyGems version?

If this is the case, you can look on /usr/lib/ruby/gems/1.8/gems/rubygems-update-x.x.x and take the directory with the highest value of x.x.x.


1 Answers

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' 
like image 69
rausch Avatar answered Sep 24 '22 00:09

rausch