taw
taw

Reputation: 18871

Which Ruby on Rails is compatible with which Ruby version?

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.

Upvotes: 104

Views: 71304

Answers (11)

hmallett
hmallett

Reputation: 1567

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.

The required ruby version in the gemspec file will at least give you an official answer for the minimum version of run. Taking that information, pls the version of Buildkite used for automated testing, on older versions, gives the following results:

Rails 7.2

  • >= 3.1.0

Rails 7.1

  • >= 2.7.0

Rails 7.0

  • >= 2.7.0

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

Upvotes: 136

Ivan Olshansky
Ivan Olshansky

Reputation: 969

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

Upvotes: 1

plypkie
plypkie

Reputation: 7

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

Upvotes: -2

Smek
Smek

Reputation: 1208

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.

Upvotes: 0

icarus
icarus

Reputation: 105

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.

Upvotes: 0

pdobb
pdobb

Reputation: 18037

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.

Upvotes: 16

gamov
gamov

Reputation: 3869

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.

Upvotes: 47

Rick Smith
Rick Smith

Reputation: 9251

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.

Upvotes: 3

dcorking
dcorking

Reputation: 1206

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.

Upvotes: 4

crazycrv
crazycrv

Reputation: 2445

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

Upvotes: 13

Marcelo Diniz
Marcelo Diniz

Reputation: 2509

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

Upvotes: 7

Related Questions