Upgrading to Ruby 2.6.3 and Rails 6.0.0rc1

Recently I was tasked with upgrading a project from Rails 5.2.1 to 6.0.0rc1 and Ruby 2.5.3 to 2.6.3.

In past encounters of upgrading Rails apps I've always run into issues upgrading gems or resolving version conflicts but this time things ran (pretty) smoothly.

First, I had to install Ruby 2.6.3. Easy, right? It should be, but after installing the latest version of OSX I had to reinstall the Xcode Command Line Tools which was a bit of a pain since I need admin privileges on my laptop. Anyway, after an update to Xcode and an install of the CLT I was on my way, Ruby was installed.

Next it was a case of changing the Rails version to 6.0.0rc1 in the Gemfile and running bundle update. This failed at first due to some version conflicts but was easy rectifiable. After the bundle had completed it was now time to run the project and watch it blow up. I didn't get that far unfortunately, the rails s command barfed due to some error with mysql2. Long story short and a few random command line flags later mysql2 was installed and the server would boot.

At first glance everything seemed to run smoothly. Now it was the time to run the specs. A quick rspec spec revealed a tonne of deprecation warnings, mainly due to case sensitive uniqueness. After these were fixed, along with a few other issues, I had the lovely sight of:

n examples, 0 failures

The upgrade was now complete. A quick check of the project was done by clicking through each page and ensuring the functionality was working as expected. A few other tasks I carried out which are noteworthy but aren't mentioned above are changing all references of update_attributes to update and also ensuring the project works with the new autoloading functionality introduced in Rails 6. This was achieved by running bin/rails zeitwerk:check and then fixing any issues that arose.

Reflecting back, this has been the easiest and stress-free Ruby and Rails update yet. Let's hope it carries on that way.

comments powered by Disqus