How Can I Specify A Minimum Ruby Version in a Gemfile?

北城余情 提交于 2019-12-23 07:00:11

问题


I know that I can specify a Ruby version in a Gemfile like so:

ruby '2.0.0'

However, instead of setting the exact Ruby version, I'd like to be able to specify a minimum Ruby version so that my scripts remain compatible with new version of Ruby.


回答1:


Already possible since Bundler 1.12, e.g.

ruby "~> 2.3.0"

see here:

https://github.com/bundler/bundler-features/issues/119




回答2:


You could raise an exception instead:

raise 'Ruby should be >2.0' unless RUBY_VERSION.to_f > 2.0


来源:https://stackoverflow.com/questions/28440712/how-can-i-specify-a-minimum-ruby-version-in-a-gemfile

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