Understanding the tilde operator in Gemfile.lock


I currently have a dependency of the following

i18n (~> 0.6, >= 0.6.4)

I've been having a read through of the Ruby Gems - Declaring Dependency Guide

And I've found out that the '~> 0.6' part means anything between 0.6 and 1.0 - correct me if that's wrong.

But I'm still confused, what does this actually mean with a second comma separated value?

A colleague believes it means

>= 0.6.4, <= 0.7

But I'm not so sure.

Show source
| ruby   | rubygems   | gemfile   2016-11-08 14:11 1 Answers

Answers to Understanding the tilde operator in Gemfile.lock ( 1 )

  1. 2016-11-08 14:11

    short answer: as pointed by Holger in the comments, ~> 0.6, >= 0.6.4 means >= 0.6.4 and < 1.0.

    The ~> operator is called pessimistic operator (or twiddle-wakka), and its objective is to guard the gems from potential bugs/failures in future releases.

    When you're building a gem, you must create a special Specification Class and put it in a .gemspec file or in a Rakefile. This class contains the information for the gem, like its name, version, license and the dependencies.

    And is a good practice specify the dependencies following a pessimistic version constraint. Therefore, notations like ~> 0.6, >= 0.6.4 are very common.

    You can find more information here.

Leave a reply to - Understanding the tilde operator in Gemfile.lock

◀ Go back