I upgraded this server to Ubuntu 12.10 last night. And, as is always the case, almost everything went smoothly, with the only exception being my memorization program. It’s a Rails app, and at least half the time I upgrade the server, something goes wrong with it.
Usually, reinstalling Passenger does the trick; last time, I had to recompile the
mysql2 gem as well, because the mysql version had changed. This time, though, no combination of recompiling and reinstalling seemed to be doing the trick. And, to make things more complicated, I’ve been stuck on an old Passenger version for a while (I think two years now?), because newer versions just hadn’t worked for me with an error that I’d never been able to find any help on by googling.
In retrospect, I think that what happened was that Ubuntu 12.10 switched to Ruby 1.9 (I haven’t verified that, I could be wrong), and so any gem without a native extension is likely to fail without recompiling? So maybe if I’d reinstalled all my gems, they would have just worked. I could be wrong, though (and the backtrace in the Apache logs seemed to be complaining about the
mysql2 gem, which I did recompile). But I decided to take this as a sign that I should really get off of my hand-grown configuration and switch to rvm. (And to Ruby 1.9, it’s ridiculous that I’ve been on Ruby 1.8 for so long.)
So I installed rvm, told it to install Ruby 1.9.3, told it to install the
passenger gems, and then went to my project and did
bundle install. And, after generating the Passenger Apache module and updating my Apache config, I restarted Apache, and things just worked!
Which was great: so nice that, when I switch to the standard community way of doing things, everything works so simply, and it turned me into a complete Bundler convert. I’m still worried about future OS upgrades, because gems could silently become incompatible with my OS libraries; still, I expect that to be a lot more manageable in the future, and now I figure that, if worst comes to worst, I’ll just reinstall everything from rvm and be up and running in 15 minutes. It is a sign of the problems that can happen if you have multiple packaging systems that are fighting with each other, but I like this a lot better than depending on Ubuntu to package all the Ruby machinery for me.
Of course, after doing this, I realized that, while my site worked, my unit tests didn’t, even run. I experimented with that this morning; upgrading to the most recent version of Rake fixed that, but there were a handful of test failures. Fortunately, all the failures turned out to be test-only, and were due to the fact that, in Ruby 1.9.3, you can no longer query membership in a range of time objects via
===, you need to use
cover? instead. I don’t understand the thinking behind that—it seems like
=== could easily use
cover? instead of
include?, and it makes ranges potentially less useful in case statements—but I’m sure there’s a reason for it. And in general it’s a reminder that I should brush up on Ruby 1.9 differences, partly to learn about gotchas but mostly to learn ways in which it can make my code look nicer.
Which is a helpful reminder of the benefits of staying up to date with versions, so I only have one or two things to change at a given time instead of lots. Which gets me worried about the other way in which I’m behind the times, namely Rails. I finally upgraded to Rails 3 a little over a year ago; I’m now technically on Rails 3.1, but I’m not using all the Rails 3.1 goodness, in particular I’m still using Prototype instead of jQuery and I’m not yet on the asset pipeline. So I really need to switch those over, and then switch to Rails 3.2. (And I’d like to do this before I fall further behind in the Rails world, I hear mutterings about Rails 4!) It’s been in my Someday/Maybe list for ages; time for it to turn into Next Actions soon, I think…
This post has not been revised since publication.