哪个 Ruby on Rails 与哪个 Ruby 版本兼容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9087116/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which Ruby on Rails is compatible with which Ruby version?
提问by taw
I have an old 2.1.1 Ruby on Rails application, with the system upgraded to use Ruby 1.8.7. It originally used 1.8.5 or so.
我有一个旧的 2.1.1 Ruby on Rails 应用程序,系统升级为使用 Ruby 1.8.7。它最初使用 1.8.5 左右。
I want to upgrade it to Ruby 1.9.x for performance reasons, and possibly to a newer Ruby on Rails as well.
出于性能原因,我想将它升级到 Ruby 1.9.x,也可能升级到更新的 Ruby on Rails。
I cannot find any easy chart of compatibility between different Ruby versions and Ruby on Rails versions.
我找不到任何简单的 Ruby 版本和 Ruby on Rails 版本之间的兼容性图表。
Will 2.1.1 work with Ruby 1.9.x? If not, how far do I need to upgrade it first, and what kind of issues am I likely to encounter? My application does complicated things to database layer, but the rest is fairly straightforward.
2.1.1 可以与 Ruby 1.9.x 一起使用吗?如果不是,我需要先升级到什么程度,我可能会遇到什么样的问题?我的应用程序对数据库层做了复杂的事情,但其余的相当简单。
回答by hmallett
This is an old question, but the fact that rails is tested against a version of ruby is a good indication that it should work on that version of ruby.
这是一个老问题,但 Rails 已针对某个 ruby 版本进行测试这一事实很好地表明它应该适用于该版本的 ruby。
Since 9th April 2019, stable branches of Rails use Buildkite for automated testing, and the list of tested ruby versions, by rails branch, is:
自 2019 年 4 月 9 日起,Rails 的稳定分支使用 Buildkite 进行自动化测试,经过测试的 ruby 版本列表,按 rails 分支,是:
Rails 6.0
导轨 6.0
>= 2.5.0
>= 2.5.0
Rails 5.2
导轨 5.2
>= 2.2.2
>= 2.2.2
Rails 5.1
导轨 5.1
>= 2.2.2
>= 2.2.2
Rails 5.0
导轨 5.0
>= 2.2.2
>= 2.2.2
Rails 4.2
导轨 4.2
>= 1.9.3
>= 1.9.3
Rails 4.1
导轨 4.1
>= 1.9.3
>= 1.9.3
Prior to 9th April 2019, stable branches of Rails since 3.0 use travis-ci for automated testing, and the list of tested ruby versions, by rails branch, is:
在 2019 年 4 月 9 日之前,Rails 3.0 以后的稳定分支使用 travis-ci 进行自动化测试,经过测试的 ruby 版本列表,按 rails 分支,是:
Rails 3.0
轨道 3.0
- 1.8.7
- 1.9.2
- 1.9.3
- 1.8.7
- 1.9.2
- 1.9.3
Rails 3.1
导轨 3.1
- 1.8.7
- 1.9.2
- 1.9.3
- 1.8.7
- 1.9.2
- 1.9.3
Rails 3.2
导轨 3.2
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.8
- 2.2.6
- 2.3.3
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.8
- 2.2.6
- 2.3.3
Rails 4.0
导轨 4.0
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 1.9.3
- 2.0.0
- 2.1
- 2.2
Rails 4.1
导轨 4.1
- 1.9.3
- 2.0.0
- 2.1
- 2.2.4
- 2.3.0
- 1.9.3
- 2.0.0
- 2.1
- 2.2.4
- 2.3.0
Rails 4.2
导轨 4.2
- 1.9.3
- 2.0.0-p648
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
- 1.9.3
- 2.0.0-p648
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
Rails 5.0
导轨 5.0
- 2.2.10
- 2.3.8
- 2.4.5
- 2.2.10
- 2.3.8
- 2.4.5
Rails 5.1
导轨 5.1
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
Rails 5.2
导轨 5.2
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
Rails 6.0
导轨 6.0
- 2.5.3
- 2.6.0
- 2.5.3
- 2.6.0
(From https://www.hmallett.co.uk/2018/08/ruby-and-ruby-on-rails-version-compatibility/)
(来自https://www.hmallett.co.uk/2018/08/ruby-and-ruby-on-rails-version-compatibility/)
回答by gamov
For versions < 3.2: http://www.devalot.com/articles/2012/03/ror-compatibility
对于版本 < 3.2:http: //www.devalot.com/articles/2012/03/ror-compatibility
For versions >= 4.0:
对于版本 >= 4.0:
- Rails 4 recommends 2.0 (src: Rails blog)
- Rails 4.1/4.2 recommends 2.1 (src: Rails former download page)
- Rails 4.2.1 recommends 2.2 (src: Rails former download page)
- Rails 5.0 requires 2.2.2+ (Rails blog)
- Rails 4 推荐 2.0(来源:Rails 博客)
- Rails 4.1/4.2 推荐 2.1 (src: Rails 前下载页面)
- Rails 4.2.1 推荐 2.2 (src: Rails 前下载页面)
- Rails 5.0 需要 2.2.2+(Rails 博客)
Rails 3.2
导轨 3.2
I tried stepping out of those recommendations (mainly running Rails 3.0 on Ruby 2.0 and 2.1), I ran in multiple weird issues.
我尝试退出这些建议(主要是在 Ruby 2.0 和 2.1 上运行 Rails 3.0),但遇到了多个奇怪的问题。
回答by pdobb
The Rails Guide on Upgrading Ruby on Rails has a section on Ruby versions. This is probably the best source as it is controlled by the Rails core team.
升级 Ruby on Rails 的 Rails 指南有一节介绍Ruby 版本。这可能是最好的来源,因为它由 Rails 核心团队控制。
As of August, 2016, the Rails Guide reads:
截至 2016 年 8 月,Rails 指南写道:
1.3 Ruby Versions
Rails generally stays close to the latest released Ruby version when it's released:
- Rails 5 requires Ruby 2.2.2 or newer.
- Rails 4 prefers Ruby 2.0 and requires 1.9.3 or newer.
- Rails 3.2.x is the last branch to support Ruby 1.8.7.
- Rails 3 and above require Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially. You should upgrade as early as possible.
1.3 Ruby 版本
Rails 在发布时通常与最新发布的 Ruby 版本保持接近:
- Rails 5 需要 Ruby 2.2.2 或更新版本。
- Rails 4 更喜欢 Ruby 2.0,并且需要 1.9.3 或更新版本。
- Rails 3.2.x 是最后一个支持 Ruby 1.8.7 的分支。
- Rails 3 及更高版本需要 Ruby 1.8.7 或更高版本。已正式取消对所有先前 Ruby 版本的支持。您应该尽早升级。
回答by crazycrv
Its difficult to find it in release notes. After googling for some time, I could only find it here http://www.devalot.com/articles/2012/03/ror-compatibility
在发行说明中很难找到它。谷歌搜索了一段时间后,我只能在这里找到它http://www.devalot.com/articles/2012/03/ror-compatibility


回答by Marcelo Diniz
From Rails 2.2 release note:(not exactly the one you asked)
从 Rails 2.2 发行说明:(不完全是你问的那个)
Along with thread safety, a lot of work has been done to make Rails work well with JRuby and the upcoming Ruby 1.9. With Ruby 1.9 being a moving target, running edge Rails on edge Ruby is still a hit-or-miss proposition, but Rails is ready to make the transition to Ruby 1.9 when the latter is released.
除了线程安全之外,还做了很多工作来使 Rails 能够很好地与 JRuby 和即将推出的 Ruby 1.9 配合使用。由于 Ruby 1.9 是一个不断变化的目标,在边缘 Ruby 上运行边缘 Rails 仍然是一个命中注定的命题,但 Rails 已准备好在 Ruby 1.9 发布时过渡到 Ruby 1.9。
I would believe that Rails 2.1.1 isn't compatible with Ruby 1.9, and you would be on your own in such an environment. You can give it a shot if your test suit is comprehensive, of course. Also, you'd have to check all the other gems used in the project which could be a real hassle.
我相信 Rails 2.1.1 与 Ruby 1.9 不兼容,在这样的环境中你只能靠自己。当然,如果您的测试服是全面的,您可以试一试。此外,您必须检查项目中使用的所有其他宝石,这可能会很麻烦。
If you choose to stick with this Rails version, I wouldn't migrate to 1.9.x. As you mentioned you would prefer upgrading it, you should probably go through the deprecations mentioned in Rails 3.0 release notesand adapt your code. A summarized list can be found in Rails 3 deprecated methods and APIs
如果你选择坚持使用这个 Rails 版本,我不会迁移到 1.9.x。正如您提到的,您更喜欢升级它,您可能应该查看Rails 3.0 发行说明中提到的弃用内容并调整您的代码。可以在Rails 3 deprecated Methods and APIs 中找到汇总列表
回答by dcorking
In general there are two places to check if a Ruby platform is suitable for your preferred Rails version.
一般来说,有两个地方可以检查 Ruby 平台是否适合您首选的 Rails 版本。
- The release announcement in the Rails blog
- The release notes in the
guides/sourcedirectory (also on the web at Rails Guidesand Github)
- Rails 博客中的发布公告
guides/source目录中的发行说明(也可以在Rails Guides和Github网站上找到)
You might also find it useful to look at the .travis.ymlfile of your version. The rvmentry there suggests the Ruby versions that the developers might run automated tests against.
您可能还会发现查看.travis.yml您的版本文件很有用。rvm那里的条目建议了开发人员可能针对其运行自动化测试的 Ruby 版本。
Naturally, use their recommendations alongside your own testing.
自然地,将他们的建议与您自己的测试一起使用。
回答by Rick Smith
Rails Guideshas information under "Getting Started with Rails". I've pull information from each version of the guides:
Rails 指南在“Rails 入门”下有信息。我从每个版本的指南中提取信息:
Rails 3.2 - The Ruby language version 1.8.7 or higher
Rails 4.0 - The Ruby language version 1.9.3 or newer
Rails 4.1 - The Ruby language version 1.9.3 or newer
Rails 4.2 - The Ruby language version 1.9.3 or newer
As far as I can tell this is as close to a primary source as you can get for minimumversions. See gamov's answerfor recommended versions.
据我所知,这与您可以获得的最低版本尽可能接近主要来源。有关推荐版本,请参阅gamov 的回答。
回答by Smek
All those pages get behind of the current state. And the documentation on the official docs are vague 'The Ruby language version ... or higher'. If you want to know what Ruby versions the Rails version you would like to know is tested against check the Travis CIthat the Rails community is using. Here you can see which branch is tested agains which Ruby version.
所有这些页面都落后于当前状态。官方文档上的文档含糊不清“Ruby 语言版本......或更高”。如果您想知道哪些 Ruby 版本,您想知道的 Rails 版本已经过测试,请检查Rails 社区正在使用的Travis CI。在这里你可以看到哪个分支在哪个 Ruby 版本中被再次测试。
Edit:
编辑:
Like hmallett mentioned Rails has changed to another testing suite. It has been changed to Built kite. You can always check the Code Status at the source repository.
就像 hmallett 提到的,Rails 已更改为另一个测试套件。它已更改为内置风筝。您始终可以在源存储库中检查代码状态。
回答by socertis
the first answer hereis quite informative, but I have a comment on the compatibility of rails-4.2with ruby-2.4.5, as there is an issue shown here, that issue makes rails-2.4.8only compatible with ruby-2.4+, any other version of rails-2.4 will not work.
这里的第一个答案信息量很大,但我对rails-4.2with的兼容性有一个评论ruby-2.4.5,因为这里显示了一个问题,该问题rails-2.4.8仅与 兼容ruby-2.4+,任何其他版本的 rails-2.4 都不起作用。

