Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set ruby version in Gemfile

Tags:

I can set ruby version in Gemfile as follows:

ruby '2.0.0' 

But what if I want to have a particular version as 2.0.0-p353?

When I add it to Gemfile, I get:

Your Ruby version is 2.0.0, but your `Gemfile` specified 2.0.0-p353 

Is it even possible to set a particular version?

like image 693
Alex Smolov Avatar asked Mar 15 '14 17:03

Alex Smolov


People also ask

How do I set gem version in Gemfile?

There are several ways to specify gem versions: Use a specific version: gem "name-of-gem", "1.0" . You can find specific versions on Rubygems.org (provided that's the source you”re using) by searching for your gem and looking at the “Versions” listed. Use a version operator: gem "name-of-gem", ">1.0" .

How do I change Ruby version on Mac?

Set Ruby version with rvm on Mac To set a default Ruby version with rvm, enter rvm --default use 3.0. 0 on the command line. To switch to the system ruby, enter rvm use system . To switch back to the default, rvm default .


2 Answers

In Version 1.3 and earlier of Bundler you couldn’t specify the patchlevel:

The ruby directive explicitly leaves out the ability to specify a patch level. Ruby patches often include important bug and security fixes and are extremely compatible.

This changed in version 1.5, the docs now say:

In the ruby directive, :patchlevel is optional, as patchlevel releases are usually compatible and include important security fixes. The patchlevel option checks the RUBY_PATCHLEVEL constant, and if not specified then bundler will simply ignore it.

So you can specify the patchlevel like this:

ruby '2.0.0', :patchlevel => '353' 
like image 140
matt Avatar answered Oct 09 '22 10:10

matt


If anyone is looking to be reminded of how to NOT specify a minor version, (yeah call me a noob) you could do:

ruby ">=2.2" 

which would allow 'bundle install' call with ruby 2.2.4.

like image 40
user3720143 Avatar answered Oct 09 '22 10:10

user3720143