Fixing Ruby Gems, MySQL and Passenger Phusion on Snow Leopard 10.6

One of the first things I noticed after upgrading to Snow Leopard is that my Passenger based sites stopped working. I use this heavily for Rails development, so I needed it fixed. The first thing I tried was reinstalling Passenger Phusion, which led to an error.

ERROR: Error installing passenger:
ERROR: Failed to build gem native extension.

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

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/passenger-2.2.4 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/passenger-2.2.4/ext/phusion_passenger/gem_make.out

There are several reasons for this.

  1. You have a new operating system with new binaries. Things don’t line up anymore.
  2. You have a new version of Ruby (1.8.7 instead of 1.8.6) and you may need updated gems.
  3. The upgrade deletes your mysql symlink

Here are the steps to take to fix the issues.

Install Xcode

This is available on the Snow Leopard DVD in the Optional Installs directory.

Install the iPhone SDK

If you have previously installed the iPhone SDK for Leopard, you’ll need to reinstall. You can download and Install the iPhone SDK for Snow Leopard. It is build specific to Snow Leopard, so be sure to grab the right dmg file.

Install MySQL 64-bit

If you are running 64-bit hardware, OS X is now fully 64-bit compliant and your MySQL libraries probably aren’t! You’ll need to download the 64-bit version and reinstall.

Next we are going to move the default data files out and restore our original data files that the install moved.

First, go stop mysql using the preference pane. I’ll wait.

Ok, now go run the following commands:

Note: You need to tailor the last command to pull from the previously installed version of MySQL. You can do an ls /usr/local/ directory to find out.

sudo mv /usr/local/mysql/data /usr/local/mysql/data.default
sudo mv /usr/local/mysql-5.0.67-osx10.5-x86/data /usr/local/mysql/data

You’ll also need to recreate the symlink for you socket.

sudo ln -s /var/mysql/mysql.sock /tmp/mysql.sock

Re-Install Your Broken Gems

Any gem that requires compilation (passenger, mysql, RedCloth, thin and hpricot are good examples) must be recompiled using the new gcc compiler that is installed with XCode.

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

You still need to pass the ARCHFLAGS command like you did under 10.5 Leopard.

More to Come?

Probably, but that’s it so far. I’ll update this post if I find any more issues.

Update 1a: Passenger PrefPane

It doesn’t load and reinstalling it doesn’t work for me. It appears to be an issue with RubyCocoa, but not sure yet. In the mean time, just add your *.local domains to to your /etc/hosts file. Thanks to David for the fix in the comments.

Once you install Ruby Cocoa 0.13.2 with the plist change (allows you to install on 10.6) you may need to change your pref pane entries. I added a letter to the alias of each, then deleted it back out and applied the change.

sudo apachectl restart

After that it picked the local domains right up and I was good to go.

Update 1b: Passenger PrefPane 1.3 is Out!

Eloy has release a new update that is compatible with Snow Leopard. Great work! Read more about it and download it on his blog.

Update 2: ImageMagick and RMagick

So the upgrade toasts Mac Ports and ImageMagick.

Yep, blow it all away. It’s too much of a pain.

rm -rf /opt/local

Now download Mac Ports for Snow Leopard and install.

You might want to go eat or get a beer for this next step. Then again, maybe not. You have a faster OS now! Nope, you still need that beer.

sudo port install libxml2
sudo port install ImageMagick
sudo gem install rmagick

Update 3: Git

I just don’t trust potential binary issues and am upgrading to the latest. You should too. WARNING: As of 8/29/2009 expat is not the correct architecture and you can’t install git yet so wait a few days. I did some testing and git seems good to go. I will upgrade as soon as this is fixed though.

Blowing away Mac Ports in Update 2 solves the issue!

If you were using Mac Ports previously, you’ll have problems you need to fix.

sudo port install git-core +bash_completion +doc

or via downloaded file

cd /download/and/untarred/folder/
sudo make install

Update 4: Fixing an Incorrect DirectoryIndex in Apache

We came across an issue this morning with Apache not using the correct DirectoryIndex (default document such as index.php). It seems the code to include the passenger prefpane vhosts has changed slightly.

In the /etc/apache2/httpd.conf file they added three new lines. It was this:

<IfModule passenger_module>
NameVirtualHost *:80
Include /private/etc/apache2/passenger_pane_vhosts/*.conf

and is now this:

<IfModule passenger_module>
NameVirtualHost *:80
<VirtualHost *:80>
ServerName _default_
Include /private/etc/apache2/passenger_pane_vhosts/*.conf

19 thoughts on “Fixing Ruby Gems, MySQL and Passenger Phusion on Snow Leopard 10.6

  1. Another tip that I ran into. I went the compiled from source route on installing ruby in the first place (1.8.6-p114). When compiling the new mysql like Greg mentioned above it went through fine but when running a project the error (Uninitialized Constant MySQLCompat) kept coming up. Resolving this is actually a pain. You must remove ruby and update to 1.8.7 as well as all ruby gems to be safe. Remove Ruby binaries in your /usr/local/bin folder as well as libruby in /usr/local/lib. Once this is complete it may be a good idea to remove all instances of readline for purposes of properly compiling 1.8.7. After which just follow the guide given by Hivelogic to install Rails on Leapard. Once you finish this reinstall the mysql gem and you should be good to go.

  2. Regarding Passenger Phusion Pref Pane:

    Download the RubyCocoa 0.13.2 Dmg file for 10.5

    move the pkg file to the Desktop and you need to edit the Info.plist file IFRequirementDicts Item 1 Test Operator to = as opposed to < (<)

    Run the pkg file after this has been saved

    After this is completed and RubyCocoa is successfully installed. the Passenger Phusion Pref Pane should work

  3. I didn’t have any problems with the passenger pref pane per se other than it causes System Preferences to restart in 32-bit mode.

    I did have to futz around with the ruby and gems installs and reinstall passenger and the apache module before passenger would actually start.

    I didn’t realize ahead of time that I’d need to reinstall macports and already installed ports. Another blog talked about this and suggested that port installed could be used to get a list of what was installed, but after upgrading to Snow Leopard it was too late, so I don’t know what I used to have installed. I guess I’ll just ‘page-fault’ them in over time.

  4. Thanks for this guide!

    David: Are you referring to line 73, the TestOperator underneath 10.6? Can we change it to &lt;= (<= instead of < as it is, or = as you recommend)?

  5. Thanks for the guide got imagemagick up. rmagick still doesn’t want to install anyone else have problems?

  6. I used “sudo port upgrade –force installed” to reinstall all my macports instead of blasting away /opt/local. Worked for me anyway.

  7. I struggled to get my ImageMagick install working properly after my SL upgrade. Then I found the post at which pointed me to a script which downloads, compiles, and installs all that is necessary to get ImageMagick working on SL. After running the script and reinstalling the rmagick gem I was good to go.

  8. This post was really helpful.
    I’m setting up a Ruby environment for the first time, and couldn’t figure out what was going on in with the MySQL Gem.

  9. Just installed mysql-5.1.44-osx10.6-x86_64 straight from, which automatically makes a symbolic link for “/usr/local/mysql -> mysql-5.1.44-osx10.6-x86_64″

    But, it doesn’t add “/usr/local/mysql/bin” to your path, so you have to do that manually.

  10. thanks a million greg.this guide really helped me a lot.hope to see some more wonderful post from ur side.

Leave a Reply