Hey, I want to say thanks for pointing me in the right direction!
Rather than completely start with new files, I new the stuff was
there, it just needed a little massaging.
Here is the account I kept of what I did to fix the problem. It’s not
the most graceful thing, but it’s not bad:
Part 1: Configuration You Never Knew You Had To Do
mysql gem manual setup for OS X 10.4.9 (probably any 10.4.x)
I’ve got Ruby 1.8.4 installed in /usr/local/bin
(I fixed the bad factory install long ago)
My mysql gem 2.7 is installed in the following directory:
My MySQL is installed in:
I have a symlink to the full name of the install to simplify the path
name. I got this idea from the way other software is often installed.
(such as the Entropy PHP distro))
You should navigate (in Terminal, using UNIX command cd) your way to
each of those directories in separate terminal windows. This should
keep you ready to check stuff. To open them as finder windows (much
easier to browse) just use OS X’s open command.
So, on my machine
The terminal window open to the mysql gem’s directory is where you
will type all of these commands.
extconf.rb has following options:
MySQL header file directory. Default is /usr/local/include.
Mine would be
MySQL library directory. Default is /usr/local/lib.
Mine would be
Same as --with-mysql-include=dir/include, --with-mysql-lib=dir/lib.
Mine would be
So, in theory, I could simply use only :
Get compile-parameter from mysql_config command.
Mine would be
Well then, let’s try this all together now, shall we? It’s long…
at the command line:
ruby extconf.rb --with-mysql-include=/usr/local/mysql/include --with-
mysql-lib=/usr/local/mysql/lib --with-mysql-dir=/usr/local/mysql –
Oops. Error message:
checking for mysql_ssl_set()… /usr/local/lib/ruby/1.8/mkmf.rb:
initialize': Permission denied - mkmf.log (Errno::EACCES) from /usr/local/lib/ruby/1.8/mkmf.rb:174:inopen’
postpone' from /usr/local/lib/ruby/1.8/mkmf.rb:541:inchecking_for’
from /usr/local/lib/ruby/1.8/mkmf.rb:600:in `have_func’
What the hell does that mean?! Well, error messages in Ruby can be a
bit cryptic, but mainly because they’re so verbose. This just said
you don’t have the matching permissions with those of the file you’re
So what to do?
Easy! Run the same command again, but start with sudo. (often
installing or configuring things at the command line in OS X requires
you to do sudo, remember that when simple commands that should work
sudo ruby extconf.rb --with-mysql-include=/usr/local/mysql/include –
(enter your password for your user account)
checking for mysql_ssl_set()… yes
checking for mysql.h… yes
Now part 2: The Test.
The documentation says:
ruby ./test.rb [hostname [user [passwd [dbname [port [socket
Ugly. That’s just too many brackets. Too many optional arguments that
are usually not optional to get anything done.
hmm… no file mysql.o
let’s skip the test and see what happens.
Part 3: Make
Now we run the make file and cross our dirty little fingers.
No. No dice.
nope, same error. Luckily, I found this earlier and it made sense:
What they said was that you need to add the line
#define ulong unsigned long long
in the mysql.c file in the mysql gem’s directory. If you are
unfamiliar with C, just open the file in TextMate and scroll down to
the first instance of #define (you will see it near the top of the
file). Insert the line after the second #define statement and you
should be fine. While you’re there though, just to be safe and
secure, add a comment line telling when you added it and why.
Ok, save and close the mysql.c file. Now run make again.
Waiting… make often takes time and don’t you dare expect to
understand half the gobbledy-gook it spits out. Make also tends to
have lengthy periods where there is no feedback on progress and all
you can do is wait and wonder. This one is a quickie though.
Ok, that was painless (I hope) now make install:
sudo make install
And that should have been super fast.
Now go play with Ruby and MySQL as you should.
CAVEAT EMPTOR: We didn’t successfully run the test.rb file. That’s
too bad. It was designed apparently for compiling the gem from source
the old-fashioned way. Or perhaps the unit test is out of date, who
knows. But it would be nice to know if everything passes! But
sometimes we must live dangerously and as we say in Texas:
If it ain’t broke, don’t fix it.