简体   繁体   English

在Gemfile中设置ruby版本

[英]Set ruby version in Gemfile

I can set ruby version in Gemfile as follows: 我可以在Gemfile设置ruby版本,如下所示:

ruby '2.0.0'

But what if I want to have a particular version as 2.0.0-p353 ? 但是如果我想要一个特定的版本为2.0.0-p353怎么2.0.0-p353

When I add it to Gemfile , I get: 当我将它添加到Gemfile ,我得到:

Your Ruby version is 2.0.0, but your `Gemfile` specified 2.0.0-p353

Is it even possible to set a particular version? 甚至可以设置特定版本?

In Version 1.3 and earlier of Bundler you couldn't specify the patchlevel : 在Bundler的1.3版及更早版本中,您无法指定补丁级别

The ruby directive explicitly leaves out the ability to specify a patch level. ruby指令明确地省去了指定补丁级别的能力。 Ruby patches often include important bug and security fixes and are extremely compatible. Ruby补丁通常包含重要的错误和安全修复程序,并且非常兼容。

This changed in version 1.5, the docs now say : 这在版本1.5中发生了变化, 文档现在说

In the ruby directive, :patchlevel is optional, as patchlevel releases are usually compatible and include important security fixes. ruby指令中, :patchlevel是可选的,因为补丁级别版本通常是兼容的并包含重要的安全修复程序。 The patchlevel option checks the RUBY_PATCHLEVEL constant, and if not specified then bundler will simply ignore it. patchlevel选项检查RUBY_PATCHLEVEL常量,如果未指定,则bundler将忽略它。

So you can specify the patchlevel like this: 所以你可以像这样指定补丁级别:

ruby '2.0.0', :patchlevel => '353'

If anyone is looking to be reminded of how to NOT specify a minor version, (yeah call me a noob) you could do: 如果有人想要提醒如何指定次要版本,(是的,我称之为菜鸟)你可以这样做:

ruby ">=2.2"

which would allow 'bundle install' call with ruby 2.2.4. 这将允许与ruby 2.2.4进行“捆绑安装”调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM