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

2

88

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

For example:

gem 'sass-rails',   '~> 3.1.5'
Tallis answered 2/1, 2012 at 10:50 Comment(3)
So it is, but a decent search didn't find that question.Tallis
No sweat! There is plenty of space on Interwebs. A little duplication is rather good. :)Ziwot
While we're mentioning duplicates, here's the oldest question that it's a dupe of: https://mcmap.net/q/181697/-meaning-of-tilde-greater-than-gt-in-version-requirementHahnert
C
107

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

Cordeiro answered 2/1, 2012 at 10:53 Comment(2)
Yes, you're right and I was way too fast with my answer and was in editing already, sorry!Cordeiro
Okay, I had been reading the gemfile manual which didn't seem to have that info. Should have just stuck to the pretty pages!Tallis
G
24

You usually use this to tell bundler that it's ok to install some minor updates (last digit specified can vary) but not to install some major update.

SO

~> 2.0.3 means >= 2.0.3< 2.1

and

~> 2.1 means >= 2.1< 3.0

Read more at https://bundler.io/gemfile.html

Gavel answered 2/1, 2012 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.