MySQL Gem on Snow Leopard

Snow Leopard does not have the mysql gem installed, and my last solution for installing it only work in OS X prior to 10.6.4; therefore, when you see the following error:

Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.


/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

Install the mysql gem with these steps:

  1. Download and install the latest version of MacPorts if not already installed
  2. Run the following commands to install mysql5 and the associated ruby gem

# sudo port install mysql5-server
# sudo env ARCHFLAGS="-arch x86_64" gem install mysql

Using Ubuntu for Time Machine in Snow Leopard

Over a year ago Matthias Kretschmann posted an excellent guide on how to use Ubuntu as a Time Machine backup server. The guide is quite well written all the configuration steps worked, but I received Error 45 creating backup disk image when Time Machine ran. Some more research revealed that this is because of changes to the sparse bundle image in Snow Leopard.

To make it work I had to create my own sparse bundle with a plist file in it to associate my MacBook’s unique id with the time machine image. Leopard and earlier releases of OS X would create a sparse disk image with the name from the network cards mac address, but in Snow Leopard it uses the computer Hardware UUID. I imagine this is because notebooks can have more than one mac address, one for wired and one for wireless.

How to create a sparse bundle in Snow Leopard

Step 1: Create the disk image with your computer’s name:

hdiutil create -size 500G -fs HFS+J -volname 'Time Machine Backup' -type SPARSEBUNDLE computer_name.sparsebundle

Step 2: Create a file called com.apple.TimeMachine.MachineID.plist inside the sparsebundle folder and fill it with the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.backupd.HostUUID</key>
    <string>UUID_STRING</string>
</dict>
</plist>

Make sure you replace UUID_STRING with your unique machine identifier. This can be found by loading System Profiler (Hardware UUID).

Step 3: Transfer the sparse bundle disk image to your Ubuntu computer:

rsync -avP computer_name.sparsebundle username@ubuntumachine:~/

Fixing MySQL Gem on Snow Leopard

NOTE: See my latest post for a solution for OS X 10.6.4 and later

A fresh Snow Leopard (OS X 10.6) install does not have the mysql gem installed, and installing it fails because of missing header files:

Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.


/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install mysql
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h

To correctly install the mysql gem:

  1. Download and install the MySQL package.
  2. Install XCode that’s bundled with Snow Leopard
  3. Install the gem for your architecture (use -arch i386 if you have an Intel Core Solo or Intel Core Duo processor):

# sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.38-osx10.5-x86_64/bin/mysql_config

Install Git on Snow Leopard

To install git on the latest version of OS X (10.6), use the git-1.6.4.2-intel-leopard.dmg (or later) package from git-osx-installer. So far it works fine for me on Snow Leopard.

I like how OS X comes with a large number of open source packages such as PHP, Apache, Vim, Subversion and Ruby on Rails; however, I’d really like to see Apple add Git to the list.