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.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
taw
  • 18,110
  • 15
  • 57
  • 76
  • 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 [RVM](https://rvm.beginrescueend.com/) – Michał Czapko Jan 31 '12 at 21:25
  • 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. – Andrew Marshall Jan 31 '12 at 21:33
  • 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+. – Joshua Pinter Feb 24 '18 at 23:23

11 Answers11

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

hmallett
  • 1,537
  • 1
  • 10
  • 11
  • Thank you. FYI the comments form on your website is not working, it requires email but there is not such field there. – Ruan Carlos Jan 31 '19 at 18:27
  • 1
    The latest version of Rails is 5.2.3. I wonder if I should install Ruby 2.6.3 for it (the latest version) – Qasim May 20 '19 at 01:11
  • 1
    There is so many dependency errors on changing to `Rails 4.1` with ruby `2.3.0` – Vishwas Nahar Jun 24 '19 at 09:59
  • Rails 4.1 can't go higher than Ruby 2.6.x – Joshua Pinter Aug 12 '20 at 04:51
  • 1
    From my experience both Rails v4.x and Rails v5.x can't go higher than Ruby v2.6.0 See also https://www.fastruby.io/blog/ruby/rails/versions/compatibility-table.html – Diego D Aug 24 '21 at 09:32
  • 1
    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. – jrochkind Jun 08 '22 at 16:57
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.

gamov
  • 3,789
  • 1
  • 31
  • 28
  • 1
    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. – Sivakumar Apr 09 '15 at 13:35
  • Similar issues as yours. As I remember, there was also methods missing and gem compatibility issues. – gamov Apr 13 '15 at 04:09
  • Rails 3.2.13 and higher supports at least Ruby 2.0: http://stackoverflow.com/a/25165358/3448554 – Kelsey Hannan Apr 20 '15 at 01:06
  • @gamov your links appear to be broken – Rick Smith Jan 22 '16 at 23:45
  • @RickSmith Yes, there is no more download page with the Rails site redesign, thanks. – gamov Jan 25 '16 at 06:48
  • @gamov I see. The requirements currently on rails guides are different and so they must have changed at some point. See [my answer](http://stackoverflow.com/a/34957813/616644) for alternate, probably newer, requirements. – Rick Smith Jan 25 '16 at 16:35
  • @gamov This answer is on 'recommendations' by the Rails team, not on minimums. – gamov Jan 26 '16 at 04:28
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.
Stefan
  • 109,145
  • 14
  • 143
  • 218
pdobb
  • 17,688
  • 5
  • 59
  • 74
  • 1
    Rails 5.1 announces support for ruby 2.4, so I assume that means rails 5.0 doesn't support it. See http://blog.michelada.io/whats-new-in-rails-51 – iheggie Jan 26 '18 at 03:40
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

crazycrv
  • 2,395
  • 2
  • 19
  • 20
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

Community
  • 1
  • 1
Marcelo Diniz
  • 2,493
  • 2
  • 21
  • 27
  • 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? – taw Feb 01 '12 at 22:16
  • 1
    @taw Then I would rather upgrade to Rails 2.3. According to the [release note](http://guides.rubyonrails.org/2_3_release_notes.html#ruby-1-9-1-support), it properly supports Ruby 1.9.1 – Marcelo Diniz Feb 02 '12 at 08:32
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.

dcorking
  • 1,146
  • 1
  • 14
  • 24
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.

Community
  • 1
  • 1
Rick Smith
  • 9,031
  • 15
  • 81
  • 85
  • 1
    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) – gamov Jan 26 '16 at 04:31
  • @gamov Thanks, I've updated my answer to state these are minimum versions. – Rick Smith Jan 26 '16 at 18:31
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.

Smek
  • 1,158
  • 11
  • 33
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.

kenlukas
  • 3,616
  • 9
  • 25
  • 36
icarus
  • 85
  • 2
  • 13
0

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

Ivan Olshansky
  • 889
  • 2
  • 17
  • 23
-2

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

plypkie
  • 7
  • 2