Snow Leopard Ugrade Nightmare

I dumped my last Windows box well over two years ago, which means the pain and suffering of OS upgrades were, unfortunately, a distant memory when I pulled Snow Leopard out of its plastic sheath last Friday. If I had flashed back to those horrible days of endless backups, clean reinstalls and upgrade utilities that did nothing like what they were supposed to, maybe I would have thought twice.

But every upgrade of OSX to this point had been painless, or nearly so. Stuff broke, certainly. But fixes were easy. And I thought that's where things were headed when I tweeted the following Friday night:

Went to Snow Leopard, and so far so good. New VPN support is killer (goodbye flaky Cisco client). Also, +30 GB of space. Nice work Apple.

What I didn't know at the time was how badly my dev environment was hosed. MySQL was working, but wouldn't talk to Ruby. My Ruby gems were completely messed up. Rails was throwing completely bizarre errors, and lots of things that should have gotten upgraded seemingly didn't.

I did do my homework ahead of time: I knew Ruby gems would have to be reinstalled. I knew MySQL was going to go south. I also expected to be able to fix these problems (both fairly minor) pretty easily. Turned out there was way more cruft on my system than I realized, and suddenly this upgrade went from an outpatient procedure to major surgery.

I'm far from a Linux/UNIX guru, and based on that alone I should have thought twice in retrospect about diving into an upgrade willy nilly. But I figured enough people had done it by now that it would be merely a matter of Googling around a bit when things went wrong. Unfortunately, it turned into a bit more of an epic than that.

Thirty-six hours (and two installs) later, my home desktop is finally up and running just like I like it, with my dev environment (Ruby + Rails + Perl + MySQL) fully restored and functional. And now that I'm done, I'm seeing some of the nice bits of Snow Leopard: increased stability, smaller footprint, 64-bit everything, great VPN support, great support for Exchange, which The Times is moving everyone to over the next few months.

But given everything, I'm not sure it was worth it, and I'm going to think long and hard before attempting to update my laptop or work machine. I think I'll stick with 10.5 for a while on those boxes. I'm writing this up hoping it helps someone out there in the same boat I was late Friday night: confused, annoyed, frustrated, defeated.

The Upgrade

The first signs of problems was Ruby itself. Snow Leopard comes with Ruby 1.8.7, but after the upgrade my Ruby was still 1.8.6. I realized why when I did a which Ruby. Apparently, I had recompiled a new version at some point, because it was pointing to the binary in /usr/local/bin, instead of /usr/bin.

OK, no problem. I got rid of the old version of Ruby, and suddenly we were in business again. It was pointing to the new 1.8.7 version of Ruby.

I decided to check out other parts of the system. For some reason, the upgrade blew away the symlink to the MySQL binary. I knew something like this would happen based on my pre-upgrade reading, and since I was using an older version of MySQL anyway, why not update it? I downloaded the .dmg from mysql, and installed version 5.1.

I then tried connecting from Ruby, and that, of course, exploded. But here too I knew that there would be problems with certain ruby gems because of incompatibility between the 32-bit and 64-bit environments of 10.5 and 10.6. No worries: I simply needed to reinstall, recompile all my gems.

I found this nifty little one-liner to reinstall all your gems in one go, and it seemed to work well. I tried to connect to MySQL again. Boom! Reinstalled the mysql gem, and tried again. Boom!

I tried recompiling Ruby, and that exploded mysteriously on me. I tried compiling MySQL from source, and that failed. I tried uninstalling everything, and reinstalling from scratch. Same problem.

I Googled around for a while trying to find an answer, and never was quite able to figure out what was going on. A few people reported the same error, but none of the solutions helped.

Time for a clean reinstall.

The Clean Reinstall

OK, this was more than I bargained for going in, but heck, I hadn't done a complete systemwide reinstall since I bought this machine, so why not start with a clean slate? Time to dive in.

After a bit more research, I came upon this HOWTO, and decided it made the most sense. I would first make a complete bit-for-bit copy of my entire system on a bootable external hard drive, and then after confirming that everything worked, I would do a clean install on my desktop, and use Apple's really outstanding migration utility to move my user info, applications and data back.

I had just cleaned up my hard drive, so I dove right in to the backup. I downloaded carbon copy cloner, and after several hours (they aren't kidding) I had a fully bootable version of my system loaded onto the external drive. I unplugged my external drive (to avoid any confusion/disaster), erased my desktop hard drive, and installed Snow Leopard, which, again, went without a hitch.

After a reboot, I used the migration utility to copy over my settings, apps and data. That also took some time, but eventually everything was back where it belonged -- what a relief!

Immediately I could see things were better: The OS was picking up the correct version of Ruby. Updating my Ruby gems was no problem, so it was time to get MySQL working.

I first tried installing via the official dmg. That worked, but I was having problems installing the new MySQL gem. I tried the top-ranked answer here but it didn't work, so I decided to delete everything (this worked) and compile from source, which is what Mac guru Dan Benjamin suggests anyway.

Using Dan's excellent upgrade guide I was able to get Ruby updated. The only problem I ran into was that same dang readline error I had before while compiling Ruby from source. I compiled an updated version of readline, but the error was still there. After some googling I found this.

Making that change in the configs worked perfectly, and Ruby compiled and installed like a champ. After tweaking my PATH, I saw this.

$ which ruby
/usr/local/bin/ruby
$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0]


Perfect.

Everything else went seamlessly, and in the end I had updated Rubygems, Rails and Ruby. I deleted MySQL (again) and followed Dan's guide for compiling it from source. That worked perfectly and after I migrated my data over to the new version of MySQL, I tried logging in from the command line client to check that everything was working correctly. It was.

And now for the real test: Could Ruby and Rails connect to MySQL? They could! The long national nightmare was over.

UPDATE: Against my better judgement, I just upgraded the laptop, which for whatever reason went much, much better than the desktop. I did an upgrade of Snow Leopard, deleted my old copy of MySQL, compiled the new version from source per Dan Benjamin's tutorial above, which worked great. Then I recompiled Ruby from source, reinstalled Rubygems and used that nifty one-liner to update all my gems. Again, went perfectly.

I had one remaining issue: Rake wasn't working right. I couldn't run tests, nor could I get any of the Rails MySQL rake commands to work. When I tried to create a database, I was seeing the exact same error mentioned here. I tried the solution suggested.

sudo env ARCHFLAGS="-arch x86_64" gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config

And all was well with the world. Hope this helps someone else out there.

UPDATE: Another smallish, but annoying, problem. After I recompiled Ruby, I noticed my buffer wasn't working in an irb session. Arrow up/down would give me "[[A" and "[[B" instead of my previous commands. Ugh. Googled around again, and found this. For whatever reason, when you recompile Ruby from source, this extension doesn't automatically get included. Odd. Anyway, it's a quick fix:

cd ext/readline
ruby extconf.rb
make
$ sudo make install

UPDATE: Another small issue. I use the Komodo IDE periodically when writing Ruby scripts (go ahead... mock me if you must). Komodo comes packaged with 32-bit versions of the debug bundle (ruby-debug-base.rb and ruby_debug.bundle). When I tried to run a script, it threw an error, saying it was the wrong architecture. Simple fix: I installed the ruby-debug-base gem, and then opened the preferences tab and added /usr/local/lib/ruby/gems/1.8/gems/ruby-debug-base-0.10.3/lib to the "Additional Ruby Import Directories" section. Fixed.

Wed, 28 Oct 2009 13:01

Tags , , , , ,

  1. By Anthony DeBarros 9 days later:


    Getting everything working must be a big relief. I’m still firmly planted in the PC world and getting ready to buy a new machine for home and move into Windows 7. I’m still on XP, so I never have used Vista or dealt with its many nightmares. I hear good things about Win7, but until everything is working the way I want it, I am sure I’ll be grinding my teeth.

    As I read your post, I thought to myself that, 30 years ago, people talked the same way about swapping the transmissions in their Camaros. The amount of sweat hasn’t changed.

Comment Snow Leopard Ugrade Nightmare


RSS