Which Ruby on Rails is compatible with which Ruby version?
Ruby on-RailsRubyRuby on-Rails Problem Overview
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.
I want to upgrade it to Ruby 1.9.x for performance reasons, and possibly to a newer Ruby on Rails as well.
I cannot find any easy chart of compatibility between different Ruby versions and Ruby on Rails versions.
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.
Ruby on-Rails Solutions
Solution 1 - Ruby on-Rails
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.
Since 9th April 2019, stable branches of Rails use Buildkite for automated testing, and the list of tested ruby versions, by rails branch, is:
Rails 6.1
>= 2.5.0
Rails 6.0
>= 2.5.0
Rails 5.2
>= 2.2.2
< 2.7
(see https://github.com/rails/rails/issues/38426)
Rails 5.1
>= 2.2.2
Rails 5.0
>= 2.2.2
Rails 4.2
>= 1.9.3
Rails 4.1
>= 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:
Rails 3.0
- 1.8.7
- 1.9.2
- 1.9.3
Rails 3.1
- 1.8.7
- 1.9.2
- 1.9.3
Rails 3.2
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.8
- 2.2.6
- 2.3.3
Rails 4.0
- 1.9.3
- 2.0.0
- 2.1
- 2.2
Rails 4.1
- 1.9.3
- 2.0.0
- 2.1
- 2.2.4
- 2.3.0
Rails 4.2
- 1.9.3
- 2.0.0-p648
- 2.1.10
- 2.2.10
- 2.3.8
- 2.4.5
Rails 5.0
- 2.2.10
- 2.3.8
- 2.4.5
Rails 5.1
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
Rails 5.2
- 2.2.10
- 2.3.7
- 2.4.4
- 2.5.1
Rails 6.0
- 2.5.3
- 2.6.0
(From https://www.hmallett.co.uk/2018/08/ruby-and-ruby-on-rails-version-compatibility/)
Solution 2 - Ruby on-Rails
For versions < 3.2: http://www.devalot.com/articles/2012/03/ror-compatibility
For versions >= 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 3.2
- 3.2.13 supports Ruby 2.0 ([Blog post][2])
- 3.2.22 supports Ruby 2.2 ([Blog post][3])
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.
[2]: http://weblog.rubyonrails.org/2013/2/27/Rails-3-2-13-rc1-has-been-released "Blog post" [3]: http://weblog.rubyonrails.org/2015/6/16/Rails-3-2-22-4-1-11-and-4-2-2-have-been-released-and-more/
Solution 3 - Ruby on-Rails
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.
As of August, 2016, the Rails Guide reads:
> ### 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.
Solution 4 - Ruby on-Rails
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
Solution 5 - Ruby on-Rails
From Rails 2.2 release note: (not exactly the one you asked)
> 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.
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.
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 notes and adapt your code. A summarized list can be found in https://stackoverflow.com/questions/3648063/rails-3-deprecated-methods-and-apis
Solution 6 - Ruby on-Rails
In general there are two places to check if a Ruby platform is suitable for your preferred Rails version.
- The release announcement in the Rails blog
- The release notes in the
guides/source
directory (also on the web at Rails Guides and Github )
You might also find it useful to look at the .travis.yml
file of your version. The rvm
entry there suggests the Ruby versions that the developers might run automated tests against.
Naturally, use their recommendations alongside your own testing.
Solution 7 - Ruby on-Rails
Rails Guides has information under "Getting Started with Rails". I've pull information from each version of the guides:
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 minimum versions. See gamov's answer for recommended versions.
Solution 8 - Ruby on-Rails
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 CI that the Rails community is using. Here you can see which branch is tested agains which Ruby version.
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.
Solution 9 - Ruby on-Rails
the first answer here is quite informative, but I have a comment on the compatibility of rails-4.2
with ruby-2.4.5
, as there is an issue shown here, that issue makes rails-2.4.8
only compatible with ruby-2.4+
, any other version of rails-2.4 will not work.
Solution 10 - Ruby on-Rails
The newest (at present) Ruby on Rails 7.0 requires Ruby 2.7.0+ and prefers Ruby 3.0+ (source).
Solution 11 - Ruby on-Rails
I believe this regression says that Rails 4.1 can't work with Ruby 2.3: https://bugs.ruby-lang.org/issues/12353