Thursday 23 February 2012

Difference between ~> and => in Gemfile

Gemfile
~> is used for pessimistic version constraint. Bundler will increment the last digit in the version provided and use that until it reaches a maximum version. So ~> 0.8.5 is semantically equivalent to:
gem "cucumber", ">= 0.8.5", "< 0.9.0"

This means that you are okay with the last digit incrementing to some arbitrary value, but the ones preceding it in the string cannot be greater than what you provided. You might do this if you think that 0.9 version is going to implement some breaking changes, but you know the entire 0.8.x release series is just bugfixes.

Bundler commands
bundle install installs the dependencies specified in the Gemfile if this is the first time you run it (and a Gemfile.lock does not exist). If a Gemfile.lock does exist, and you have not updated you Gemfile, bundler will fetch all remote sources, but use the dependencies specified in the Gemfile.lock instead of resolving dependencies.

References:
http://stackoverflow.com/questions/4292905/what-is-the-difference-between-and-when-specifying-rubygem-in-gemfile

No comments :

Post a Comment