/ DEVELOPMENT

How to un-update in bundler

A while ago, I made a mistake.  I know, I know: “That never happens!”.  Well, it did.  As you may know, we make this little online service www.DayhomeRegistry.com and the magic behind the curtain there is Ruby on Rails.  If you’ve ever worked with RoR, you know it can be a rat’s nest of interdependent gems working to “make the magic happen” (tm).  Under the guidance of our good friends at Burmis Studio we use Bundler to make the management of all those sparkly little gems hang together well.  It has these great features that let you install all the dependencies you need from bare metal with one command.  It lets you see all the dependencies for each gem and in a single step it can update all the gems in your Gemfile to their latest versions.  Uh oh.  It does what?  And the dependencies too? And…oh…that wasn’t what I wanted. Undo.  Wait, what do you mean there’s no undo?  Crap.  Well, this is the story of un-updating a bundler update.

First, you have to understand a few things about Gemfiles that, for a newb like me, have implications beyond the obvious.  First, when I looked at the Gemfile, Capistrano was no where to be seen.  I knew I was using capistrano….the “cap” command was a dead giveaway, but it wasn’t until I ran the gem dependency checker that I figured it out: But what, you ask, is the (~> 2.11) for?  Well that my friends, was the crux of this entire problem.  That little symbol basically says “the latest you’ve got greater than or equal to versino 2.11”.  When I upgraded using bundler, since the spec doesn’t include a max value….I upgraded automagically to 2.13.3.  Now, the Gem file specs this out this way to ensure that you’re able to easily stay up to date.  Locally, this was no issue.  On the test machine, no issue.  But then I deployed to our prod machine, and all hell broke loose.  I don’t have a spiffy screen shot, but lets just say that an upgrade to capistrano locally made for a very bad capistrano deployment onto the prod server.  Trying to upgrade capistrano on the server made an even bigger mess, crashing nginx and passenger in a very strange way.  We ended up having to revert the prod server to an older image.

So my next thought was, “no problem, I’ll just use the handy Gemfile to force capistrano to the older version.” One quick edit and…

Huh.  That didn’t get rid of 2.13.3.  And to make matters worse, I have activated the newer version and apparently can’t go back to the older one.  Sigh. Thankfully I stumbled across the gem uninstall tool. This little doodad, is smart enough to know about all the versions you’ve deployed and let you get rid of just a single one….exactly what I wanted:

Of course, the fanfare update needed to be uninstalled too:

So at the end of the day, Bundler is great for installing a known set of gems, and for upgrading them auto-magically.  But you still need to have a good handle on manual gem manipulation if you need to uninstall.  Hope this helps someone who’s dealing with the same issue in the future skip straight to the solution. Goes to show that abstractions aren’t always what they’re cracked up to be.

jonmholt

Jon Holt

A coach, an entrepreneur, and a no-bull advisor in growing small businesses through the use of practical strategy, light-weight governance and sitting back and thinking about running your business, regardless of what you do.

Read More