02-Nov-2015 15:19

Updating gem

What are the best-practices for upgrading gems to newer versions?What sort of tips and techniques can save time and headaches?

Here’s my favorite reasons for keeping gems relatively current: That being said, recent versions can have new bugs, so it’s best to avoid versions that are unreleased or that haven’t aged at least a few weeks.Once you’ve updated your gems, then try out your favorite techniques for speeding up running tests. Then the issue becomes one of figuring out which related gems you might want to update to fix the test failure.If you don’t have good tests coverage, a great place to start is with integration tests that do the basics of your app.At least you’ll be able to quickly verify a good chunk of your app can at least navigate the “happy path” as you iterate updating your gems.If you’ve updated gems recently, sometimes you can run and everything works great.Large libraries, like Rails, RSpec, Twitter Bootstrap, etc. Typically if a major version number is updating, like Rails 3.x to 4.x and RSpec 2.x to 3.x, that’s going to require lots of code changes. Going from Rails 3.x to Rails 4.x is more difficult than Rails 4.0 to Rails 4.1.

There’s a similar story with RSpec 2.x to 2.99, compared to going to RSpec 3.0.

Unless you have a good reason, don’t lock a gem to a specific version as that makes updating gems more difficult.

In general, consider only locking the major Rails gems, such as rails, RSpec, and bootstrap-sass, as these are the ones that will likely have more involved upgrades. It’s not necessary to introduce the added complexity of the test accelerators when doing major library updates. Naturally, it’s an iterative process to get tests passing when updating gems. You can try updating the gems one by one until you get a test failure.

Recently, that strategy failed miserably when I tried going from Rails 4.0 with RSpec 2.2 to Rails 4.1 and RSpec 3.

An eariler attempt shortly after the releases of Rails 4.1 and RSpec 3 clearly showed that many dependent gems would have to get updated.

A few months later, I still had many issues with trying to update too much at once.

Profile for updating gem:

updating gem-35updating gem-74updating gem-78

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “updating gem”