Home > other >  looking for recommended upgrade path for app (ruby 2.3.8 , rails 4.2.11) to the latest stable versio
looking for recommended upgrade path for app (ruby 2.3.8 , rails 4.2.11) to the latest stable versio

Time:05-30

as the title states, I'm looking for a recommended path for app (ruby 2.3.8 , rails 4.2.11) to the latest stable versions of ruby and rails, that is the safest, most stable option for a very, very large codebase.

e.g.

  • is it better to first upgrade ruby to 2.4 , then 2.5 and so on, and then come back around to upgrading rails in small steps (e.g. 4.2 => 5.0.x => 5.1.x => ...) ?

  • what ruby version is the latest version that can be used to run rails 4.2.x ?

any recommendations / guidance would be greatly appreciated.

CodePudding user response:

The first step is to make sure that your application has enough tests to give you confidence during upgrading the application.

Then you can start the actual upgrade process. There are different ways to do this. I usually suggest updating in smaller steps, instead of huge all in once upgrades, because that makes it much easier to fix issues along the way because you know exactly with Ruby or Ruby on Rails version introduced the issue.

Additionally, each Ruby on Rails version has a range of Ruby versions they are compatible with and you have to update them in matching combinations.

Some people suggest that you should upgrade to the lowest minor and patch version first and then to the latest minor, for example, like 5.0.7.2 -> 5.1.0 -> 5.1.7. But in my experience, it is fine to update directly to the latest version of the next minor version, like 5.0.7.2 -> 5.1.7.

I suggest following this table with Ruby and Ruby on Rails compabilities. This leads to the following upgrade path:

ruby 2.3.8   rails 4.2.11    your current versions
                   |
ruby 2.3.8   rails 4.2.11.3
                   |
ruby 2.3.8   rails 5.0.7.2
     |
ruby 2.4.10  rails 5.0.7.2
                   |
ruby 2.4.10  rails 5.1.7
     |
ruby 2.5.9   rails 5.1.7
                   |
ruby 2.5.9   rails 5.2.8
     |
ruby 2.6.10  rails 5.2.8
                   |
ruby 2.6.10  rails 6.0.4.8
                   |
ruby 2.6.10  rails 6.1.6
     |
ruby 2.7.6   rails 6.1.6    minimum combination to still get security fixes
     |
ruby 3.0.4   rails 6.1.6
                   |
ruby 3.0.4   rails 7.0.3    minimum combination to still get bug fixes
     |
ruby 3.1.2   rails 7.0.3    latest (summer 2022)

Note that at the time of writing this answer (summer 2022) Ruby 2.7 and Ruby on Rails 6.1.x still get security fixes. Therefore I would suggest that to be the lowest version combination to run on production. Bug fixes are only available for Ruby 3.0 and Ruby on Rails 7.0.x and above.

During each step consult Upgrading Ruby on Rails in the official Rails Guides about what changed in that specific version. After each step, make sure to fix all deprecation warnings that might occur.

Please keep in mind reviewing all your other gems too. I would consider it a good practice to update all gems to the latest versions that are compatible with your current Ruby and Ruby on Rails combination after each step and before making the next upgrade step.

  • Related