24

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?

Alex Smolov
  • 1,831
  • 4
  • 24
  • 43

2 Answers2

24

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'
matt
  • 78,533
  • 8
  • 163
  • 197
  • 2
    Just noticed that you need to specify `patchlevel` as a string. Otherwise, `bundler` would error: `The Ruby patchlevel in your Gemfile must be a string`. – Alex Smolov Mar 15 '14 at 21:16
  • 3
    @AlexSmolov it looks like you’re right. The docs must be wrong. A string is used in the [Gemfile manual](http://bundler.io/v1.5/man/gemfile.5.html) though. – matt Mar 15 '14 at 21:26
17

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.

user3720143
  • 179
  • 1
  • 2
  • I can't find the doc for this but can find this changelog https://bundler.io/v1.12/whats_new.html#ruby-version-locking. You can also do like this `ruby "~> 2.2"` – Linh Dam Aug 25 '19 at 09:16
  • @LinhDam, did you mean `~> 2.2.0`? – Nakilon Sep 02 '20 at 10:16