Installing Rails on Mac OS X Tiger (10.4.8)

Posted on Mon Oct 16 17:56:00 UTC 2006

Just a few days ago, I had the opportunity to upgrade my iMac from a 20” to a 24”. Not only does it have more real estate on the screen, not only is the CPU slightly faster, but it also can take up to 3 Gb of RAM, from 2Gb, which is quite an improvement, especially if you like to run multiple VMs (using Parallel).

So it was quite a relief to us my notes to install Rails on Mac OS Tiger. Except that a lot has changed in the past 3 months since I last wrote that article, and before I update the page to make more sense to newcomers, I’ll just write down a few notes on what I had to do differently.

These reflect the installation on MacOS 10.4.8 and the latest version of MacPorts (as of 10/14/06).

First of all, Darwin Ports is no more: long live MacPorts!

Which means that here is a new location for darwin ports installer.

Then I uncovered a problem in the order of the steps:

Set the PATH before running “sudo port -d selfupdate”, not after as suggested.

One thing that I did not realize, is that you need to actually install a C compiler before you can get started! The easiest is to install XCode 2.4. There is a free registration you need to fill in.

I missed a sudo:
cp httpd.conf.sample httpd.conf => sudo cp httpd.conf.sample httpd.conf

The path to the launchctl file for apache2 has changed:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist instead of sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.apache2.plist
To initialize the database, you need to add:
add "sudo -u mysql mysql_install_db5"
The path to the launchctl file for mysql5 has changed as well:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist instead of sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.mysql5.plist

replace rb-mysql5 with rb-mysql since rb-mysql supports both flavors

And that’s where it got a bit tricky. With that combination of MacOS 10.4.8 and the current version of MacPorts, rb-mysql fails to compile.

gcc -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin8.8.1 -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/opt/local/include/mysql5/mysql/ -I/usr/local/include -O -pipe -I/opt/local/include -fno-common -O -pipe -I/opt/local/include  -fno-common -pipe -fno-common  -c mysql.c
mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
{standard input}:6318:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000065$pb" 
{standard input}:6318:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:5382:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000045$pb" 
{standard input}:5382:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:5355:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000044$pb" 
{standard input}:5355:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:5333:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000044$pb" 
{standard input}:5333:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:4861:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000042$pb" 
{standard input}:4861:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:4359:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000041$pb" 
{standard input}:4359:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:4106:non-relocatable subtraction expression, "_eMysql" minus "L00000000041$pb" 
{standard input}:4106:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3957:non-relocatable subtraction expression, "_cMysqlTime" minus "L00000000040$pb" 
{standard input}:3957:symbol: "_cMysqlTime" can't be undefined in a subtraction expression
{standard input}:3895:non-relocatable subtraction expression, "_eMysql" minus "L00000000040$pb" 
{standard input}:3895:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3824:non-relocatable subtraction expression, "_eMysql" minus "L00000000039$pb" 
{standard input}:3824:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3803:non-relocatable subtraction expression, "_eMysql" minus "L00000000038$pb" 
{standard input}:3803:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:3256:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000023$pb" 
{standard input}:3256:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:3226:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000022$pb" 
{standard input}:3226:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:3200:non-relocatable subtraction expression, "_cMysqlRowOffset" minus "L00000000022$pb" 
{standard input}:3200:symbol: "_cMysqlRowOffset" can't be undefined in a subtraction expression
{standard input}:2749:non-relocatable subtraction expression, "_eMysql" minus "L00000000019$pb" 
{standard input}:2749:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:2595:non-relocatable subtraction expression, "_eMysql" minus "L00000000018$pb" 
{standard input}:2595:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:2412:non-relocatable subtraction expression, "_cMysqlStmt" minus "L00000000016$pb" 
{standard input}:2412:symbol: "_cMysqlStmt" can't be undefined in a subtraction expression
{standard input}:973:non-relocatable subtraction expression, "_eMysql" minus "L00000000008$pb" 
{standard input}:973:symbol: "_eMysql" can't be undefined in a subtraction expression
{standard input}:290:non-relocatable subtraction expression, "_cMysqlField" minus "L00000000004$pb" 
{standard input}:290:symbol: "_cMysqlField" can't be undefined in a subtraction expression
{standard input}:232:non-relocatable subtraction expression, "_cMysqlRes" minus "L00000000003$pb" 
{standard input}:232:symbol: "_cMysqlRes" can't be undefined in a subtraction expression
{standard input}:190:non-relocatable subtraction expression, "_eMysql" minus "L00000000002$pb" 
{standard input}:190:symbol: "_eMysql" can't be undefined in a subtraction expression
make: *** [mysql.o] Error 1

At this point your are either stuck waiting for an update version, or if you are not afraid to dip into the code, you can arm-twist it into working by following these steps:

rb-mysql patch

These steps should be fairly simple to follow:
cd /opt/local/var/db/dports/build/_opt_local_var_db_dports_sources_rsync.rsync.darwinports.org_dpupdate_dports_ruby_rb-mysql/work/mysql-ruby-2.7.1
sudo ruby extconf.rb --with-mysql-include=/opt/local/include/mysql5/mysql/ --with-mysql-lib=/opt/local/lib/mysql5/mysql/
add '#include "my_global.h"' to mysql.c (as the first #include)
sudo make clean
sudo make
sudo make install

And voila. Running the tests will show 3 failing tests, mostly due to imprecisions, but I think you can live with them. Further testing with rails apps did not reveal any problems with MySQL access.

Note: I’ve contacted the maintainer of that port but I have not heard back yet. I will update this post when I do.

A few bonus gems I’ve found helpful, or can’t live without

And since you are in setup mode, you might as well add them to your collection.

sudo gem install acts_as_versioned ajax_scaffold_generator BlueCloth builder fastercsv ferret gettext  htmltools mocha payment radiant  radius rcov rdig RedCloth ruby-debug rubyful_soup selenium shipping
sudo gem install map_by_method what_methods

A word from nano RAILS sponsors

The business of web hosting has a strong influence over the internet as a web site can not exist without hosting services. Whether it is a microsoft certifications web site or a web site with original material about home based business work. The leading web hosts provide different types of hosting packages such as domain or email hosting. Along with other comprehensive services such as web site development.  Sites do needs proper search engine submission in order to capture a good rank, whether it is a web site for online certification or a site for holiday planning.

Posted in Mac, Rails  |  Tags  |  8 comments

Switching back to MacOS

Posted on Mon Jun 19 17:07:00 UTC 2006

The main reason for switching back to MacOS is the switch back to Intel. That had been the main inhibitor for a long time. I have a few sotwares that only run on Windows and with Parallels, this looks like it is going to be easy to run them. So for father’s day, I got a shiny new 20” iMac (Thank you!). I have been quite impressed with Apple lately, both from a Design perspective, but also from their overall strategy and execution of that strategy. What a change from that near death experience. The iMac is really a neat machine. The screen quality is outstanding, and the speed is great; I haven’t done any benchmarks, but just judging by how Firefox behaves, that’s pretty impressive.

Over the years I’ve used computers, I have probably used the whole spectrum of personal computers. Primarily Windows and Linux for the past 10 years. Macs for the 5 years before that. I was never quite out of the Mac altogehter since my wife insisted that she needed a Mac (having worked at Apple and all that…), but that wasn’t mine, I was just doing the support if something went wrong.

My first Mac was a Mac IIx, with a whopping 1Mb of RAM, courtesy of Apple France, back in 1989. That wasn’t my first computer, that one was a ZX81 from Sinclair, with 2Kb of RAM. Seems hard to imagine now. Especially now that my shiny new iMac came with 512Mb, and I felt that wasn’t quite enough, so I had to go to Fry’s and get 2Gb. Now that’s better!

Installing the RAM was a no brainer. I only found that Apple article after the fact, but it was easy to figure out, plus underneath the base, there are some instructions too. There are only 2 apparent screws on the whole things, plus a couple or torx ones, but I started with the regular ones, and bingo, there was the RAM.

So now I’m off with my hair on fire running around and setting things up. I’ve got quite a long list of things to install, figure out and tinker with. Things like updating Ruby, install TextMate, get an Rails app running, … I’ve already scoped out a few pointers in case I run into trouble.

Oh, there’s one more thing I could not stand for very long: the single-button-no-wheel-mouse! As part of the same trip to Fry’s, I got a bluetooth mouse from macally, the BTMOUSEJR and I can now scroll, and context click right from the mouse. The Apple mouse is really slick looking, and totally unpractical too! Steve, do something please ;) I have had some trouble with that mouse after the system came back from sleep mode, because it was no longer paired, but after reading the FAQ, it was just a matter of clicking the left and right button for a few seconds, and the mouse wakes up and everything is fine.

So over the upcoming weeks, in addition to Debina/Ubuntu stories, you can expect to also see quite a few Mac related posts.

Now, back to my long list, starting with Windows and Dapper Drake… I’ll keep you posted!

Posted in Mac, News  |  Tags  |  0 comments