Which Ruby on Rails is compatible with which Ruby version?
Asked Answered
I

11

102

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.

Irwinirwinn answered 31/1, 2012 at 21:19 Comment(3)
I don't know exactly which version of Ruby on Rails works with which Ruby, but I think the best way to test different versions compatibility is to install RVMBaugh
It's unlikely Rails 2.1.1 supports Ruby 1.9, as Ruby 1.9.0 was known to be very buggy with Rails, and Ruby 1.9.1 was released after Rails 2.1.1.Handpick
The last version of Ruby that Rails 3.2.22.5 supports is Ruby 2.3.6. After that, you'll need to update Rails to 4+.Zepeda
F
133

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

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/)

Footless answered 12/8, 2018 at 15:18 Comment(6)
Thank you. FYI the comments form on your website is not working, it requires email but there is not such field there.Kafir
The latest version of Rails is 5.2.3. I wonder if I should install Ruby 2.6.3 for it (the latest version)Lumberyard
There is so many dependency errors on changing to Rails 4.1 with ruby 2.3.0Michellemichels
Rails 4.1 can't go higher than Ruby 2.6.xZepeda
From my experience both Rails v4.x and Rails v5.x can't go higher than Ruby v2.6.0 See also fastruby.io/blog/ruby/rails/versions/compatibility-table.htmlExasperate
Where have you found evidence that Rails 6.0 works/is supported with ruby 3.0? Some other people (like the fastruby chart) suggest max ruby 2.7 for Rails 6.0. I am unsure how to figure this out.Tripos
D
47

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

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.

Dithyrambic answered 8/5, 2014 at 3:57 Comment(7)
can you please elaborate on the weird issues you ran into. We are trying to run rails 3.2.19 on ruby 2.1.5 and facing lot of weird errors related to queries generated by ActiveRecord.Dogmatism
Similar issues as yours. As I remember, there was also methods missing and gem compatibility issues.Dithyrambic
Rails 3.2.13 and higher supports at least Ruby 2.0: https://mcmap.net/q/212122/-can-i-update-to-ruby-2-1-2-using-rails-3-2-3Pampuch
@Dithyrambic your links appear to be brokenAdagio
@RickSmith Yes, there is no more download page with the Rails site redesign, thanks.Dithyrambic
@Dithyrambic I see. The requirements currently on rails guides are different and so they must have changed at some point. See my answer for alternate, probably newer, requirements.Adagio
@Dithyrambic This answer is on 'recommendations' by the Rails team, not on minimums.Dithyrambic
M
16

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.
Munificent answered 6/8, 2016 at 11:9 Comment(1)
Rails 5.1 announces support for ruby 2.4, so I assume that means rails 5.0 doesn't support it. See blog.michelada.io/whats-new-in-rails-51Dorsiventral
F
13

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

Ruby Rails Version Compatibility

Freckly answered 26/12, 2012 at 13:44 Comment(3)
This is quite outdated now... I wouldn't rely on this anymore.Snowinsummer
Yes, the table here is outdated, please see my updated answer.Dithyrambic
If you try Rails 4 with Ruby 1.9.3 you get an error saying you need Ruby v 2.2.2 or higherMalvinamalvino
T
7

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 Rails 3 deprecated methods and APIs

Townswoman answered 31/1, 2012 at 21:41 Comment(2)
I mostly want Ruby 1.9 for performance reasons, and want to upgrade Rails as little as possible while still being able to use Ruby 1.9.x for now since this will cause problems. Will Rails 2.2 work with Ruby 1.9?Irwinirwinn
@Irwinirwinn Then I would rather upgrade to Rails 2.3. According to the release note, it properly supports Ruby 1.9.1Townswoman
S
4

In general there are two places to check if a Ruby platform is suitable for your preferred Rails version.

  1. The release announcement in the Rails blog
  2. 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.

Silicone answered 6/8, 2014 at 16:8 Comment(0)
A
3

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.

Adagio answered 22/1, 2016 at 23:44 Comment(2)
Be careful with this because there is also a maximum Ruby version a Rails version can use. See my answer (e.g. Rails < 3.2.22 doesn't support Ruby 2.2)Dithyrambic
@Dithyrambic Thanks, I've updated my answer to state these are minimum versions.Adagio
B
0

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.

Blanchblancha answered 7/3, 2019 at 8:18 Comment(2)
Travis CI hasn't been used for Rails since 9th April 2019.Footless
You are right they have changed to another test suite. I edited my answer.Blanchblancha
E
0

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.

Ezequieleziechiele answered 16/9, 2019 at 14:50 Comment(0)
J
0

The newest (at present) Ruby on Rails 7.0 requires Ruby 2.7.0+ and prefers Ruby 3.0+ (source).

Jepum answered 30/3, 2022 at 17:4 Comment(0)
J
-2

I believe this regression says that Rails 4.1 can't work with Ruby 2.3: https://bugs.ruby-lang.org/issues/12353

Jeggar answered 5/9, 2020 at 20:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.