Rails and MySQL on Leopard Server
Leopard Server ships with MySQL and Ruby on Rails. So far, so good.
But when you fire up a Rails app that uses MySQL:
$ ruby script/server
and access something that hits the database, you get this:
WARNING: You're using the Ruby-based MySQL
library that ships with Rails. This library is not suited
for production. Please install the C-based MySQL library
instead (gem install mysql).
The fun has just begun. Try to install the mysql gem (enter “3” and press return when prompted):
$ sudo gem install mysql
Select which gem to install for your platform (universal-darwin9.0)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 3
Congratulations, the install has failed:
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.
Your next move is to Google for a solution for a couple of hours. Yes, other people are having this problem, and no, none of them are running Leopard Server, so their solutions won’t work. What next?
Submit a bug to Apple making this series of irrefutable points:
- Leopard Server ships with Rails.
- Leopard Server ships with MySQL.
- Leopard Server is a production-ready operating system.
- Rails, as shipped in Leopard Server, is not production-ready (see previous item).
Receive a (timely, thank you Apple) response reminding you that the MySQL client libraries don’t ship with Leopard Server, so why don’t you install them, per this article?
Having installed the client libraries, spend another hour on Google until you figure out the magic:
$ sudo gem install mysql -- \ --with-mysql-include=/usr/include/mysql \ --with-mysql-lib=/usr/lib/mysqlEnter “3” again, and you’ll see:
Building native extensions. This could take a while... Successfully installed mysql-2.7
Ah yes. The pain, she has go away.
0 TrackBacks
Listed below are links to blogs that reference this entry: Rails and MySQL on Leopard Server.
TrackBack URL for this entry: http://www.craptasm.org/cgi-bin/mt/mt-tb.cgi/4

Leave a comment