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

*爱你&永不变心* 提交于 2019-11-29 10:43:10

问题


My question is pretty much in the title.

e.g. in the default Gemfile created with a Rails 3.1 app;

gem 'sass-rails',   '~> 3.1.5'

It seems like I should know this already but I can't find any reference to it on the Bundler website.


回答1:


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 http://gembundler.com/gemfile.html and http://guides.rubygems.org/patterns/#pessimistic-version-constraint




回答2:


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 http://gembundler.com/gemfile.html



来源:https://stackoverflow.com/questions/8699949/what-does-the-symbol-mean-in-a-bundler-gemfile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!