MySQL, Snow Leopard and ruby

I got a shiny new MacBook Pro on the weekend, yay! After months of complaining about the slowness and the heat evaporating from my old Macbook, I’m finally off to better grounds.

But then there was the annoying task of setting up the machine with all the software that I’m using. MySQL and ruby turned out to be particular problems. I installed MySQL for 10.5, since MySQL haven’t published one for OS 10.6 yet. I ran “gem install mysql”. And then the pain started.

I got all the errors that were reported elsewhere:
uninitialized constant MysqlCompat::MysqlRes” and “undefined method `real_connect’ for Mysql:Class (NoMethodError)“. I tried all the suggestions – including:
"sudo env ARCHFLAGS="-arch x86" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.39-osx10.5-x86/bin/mysql_config -V --debug, but just couldn’t get there.

My laptop reports in the System Software Overview: “64-bit Kernel and Extensions: No”, so I assumed I had to use the 32 bit versions. However, that was a wrong assumption. Even though my kernel seems to be 32 bit, applications seem to be 64 bit.

So, eventually I re-installed MySQL for Mac OS X 10.5 (x86_64) and ran the correct gem install command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql-5.1.39-osx10.5-x86 and things were fine.

Additionally, there was some fighting with the PrefPane and re-starting mysql. I had to kill it manually and I had to install the updated PrefPane of Swoon dot net to make it work.

Hope this helps somebody avoid the same pain!

4 thoughts on “MySQL, Snow Leopard and ruby

  1. This helped me get the architectures correct but I still got the ‘undefined method “real_connect” ‘ problem.
    I finally tracked down the problem. I had an old version of the gem in my local cache (~/.gem/…).
    I deleted all cache refs to the old version and all was well.
    May be a bug in gem that it doesn’t clean the local cache when gems are uninstalled ??

  2. I had the same problem on Snow Leopard. I tried your gem installation command, but the mysql gem I was installing (2.8.1) grumbled at the extra ‘–width-mysql-config’ build flags. Fortunately, since the mysql installation creates a softlink to /usr/local/mysql I was able to omit that and just issue:

    sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql

    and it worked fine.

  3. Only thing that solved this for me was doing this:

    sudo env ARCHFLAGS=”-arch x86_64″ gem install ruby-mysql

    rather than this:
    sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql

Comments are closed.