Rails: Vulnerability on REXML RailsConf Europe 2008: heading to berlin!
Aug 28

So I couldn’t resist and bought myself a MacBook Pro! It’s my first week with my new toy and I’m really enjoying it.

But I need to do something useful with it so I started to prepare it to be my new development platform, starting with Ruby/Rails + MySQL: Here is where the fun begins!

After I installed both Rails and MySQL, I fired up a terminal an typed:

sudo gem install mysql

…and here is what u get

ERROR: Failed to build gem native extension.

If you google this error you will find a couple solutions and this is the one that worked for me:

ARCHFLAGS="-Os -arch x86_64 -fno-common"
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
--with-mysql-config=/usr/local/mysql/bin/mysql_config

Now, confident enough, I created a sample rails app and tried to create the development database:

leo$ rake db:create (in /Users/leo/projects/test)
dyld: lazy symbol binding failed: Symbol not found: _mysql_init

Doesn’t look happy yet huh? This took me a while to figure out but it turned out to be fairly simple.
I have no idea why but after I installed the gem I had the file mysql.bundle in two different places:

/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
/Library/Ruby/Gems/1.8/gems/mysql-2.7/mysql.bundle

The solution was to remove the first copy of the file. Now everything is working fine at this end!
I really hope this is useful to someone!

Related Posts

3 Responses to “Mac OS X: Getting MySQL and Rails to work”

  1. Loquito says:

    Booooo, come back to Linux, the best operating system in the world. LOL. I’m just kidding. Being a Linux person it is hard to say, but Mac OS is probably the best Unix type OS available if you want a stable OS. It is built so all the parts work with each other seamlessly, and all the hardware always works with the software. I use Ubuntu, and although they are closer to this goal than say 5 years ago, it still in quite a poor state. I think that Ubuntu should go the way of Apple and choose a limited set of hardware, and get all their software to work on that hardware. The benefits would be that obviously you would know that all your software would work with the hardware you had, and because it would not be proprietary hardware like apple use the hardware cost would be much lower.

    But for now, until apple cost their hardware sensibly or someone buys me one, I am Ubuntu/Linux.

  2. Hahahaha

    That’s exactly what motivated me to move o Mac.

    So far, I can’t complain.

  3. Pete says:

    Brilliant, this worked perfectly for me having tried all the other solutions i then came across this, the most obvious one! ha.

Leave a Reply

preload preload preload