Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the ~> symbol mean in a bundler Gemfile? [duplicate]

What does the -> mean next to a version number in a Gemfile?

For example:

gem 'sass-rails',   '~> 3.1.5' 
like image 855
brad Avatar asked Jan 02 '12 10:01

brad


People also ask

What is ~> Gemfile?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

What does this mean ~>?

It means "equal to or greater than in the last digit", so e.g. ~> 2.3 means "equal to 2.3 or greater than 2.3, but less than 3.0", while ~> 2.3.

What is bundled with in Gemfile lock?

Ruby apps will now have the `BUNDLED WITH` declaration in their `Gemfile. lock` removed after detecting Bundler version. The version listed in the BUNDLED WITH key of the Gemfile. lock is used by Heroku to detect what version of Bundler to use.

Should Gemfile lock be checked in?

The Gem Development guide says that the Gemfile. lock file "should always be checked into version control." However, this is NOT true for Gems. For Applications, like your Rails apps, Sinatra apps, etc., it is true. The same does not go for Gems.


1 Answers

From the bundler website:

The specifier ~> has a special meaning, best shown by example:
'~> 2.0.3' is identical to '>= 2.0.3' and '< 2.1.'
'~> 2.1'     is identical to '>= 2.1'    and '< 3.0'.
'~> 2.2.beta' will match prerelease versions like '2.2.beta.12'.

See https://bundler.io/gemfile.html and http://guides.rubygems.org/patterns/#pessimistic-version-constraint

like image 144
Tim Brandes Avatar answered Sep 25 '22 16:09

Tim Brandes