Why does a Gem provide ~> AND => in RubyGems?
'~> 3.1'
means the required version can be 3.1.x
or 3.2.x
or 3.3.x
or ..., but never to reach 4.0
.
The meaning of '>= 3.1.11'
is quite clear.
So put them together, it means the version can be 3.x.y
where x >= 2
or x = 1 and y >= 11
.
Maybe this notation is more clear:
gem 'bcrypt', '>= 3.1.11', '< 4'
>= 3.1.11
is an “optimistic” version constraint. It’s saying that all changes from 3.1.11
on will work, but for version 4.0.0
this will not be true.
~> 3.1
is “pessimistic”. This explicitly excludes the version that might break your code. It is basically saying >= 3.1
and < 4.0
. But if you had ~> 3.1.1
, it will be equal to >= 3.1.1
but less than 3.2
If you want to allow use of newer backwards-compatible versions but need a specific bug fix you can use a compound requirement like '~> 3.1', '>= 3.1.11'
This is detailed at http://guides.rubygems.org/patterns/#pessimistic-version-constraint If you want to allow use of newer backwards-compatible versions but need a specific bug fix you can use a compound requirement such as... '~> 2.2', '>= 2.2.1'