Home > Mac OS X Tips > Snow Leopard, 64bits, Ruby and MySQL

Snow Leopard, 64bits, Ruby and MySQL

I recently started again wanting to play a little bit with the so acclaimed Ruby on Rails framework. Being on a Mac, I had not much to do to start working, with Ruby & RoR already installed with my Snow Leopard default OS X install (maybe because I’ve already installed the XCode Developer package, as well as the iPhone’s one… maybe you should check). So I was playing with my Ruby on Rails’ guide and I had already started building a project, having it displayed in my browser, so I knew the core of the install was up and ready.

Next step was to connect with MySQL. It proved not to be so simple as expected… Running rake db:migrate to check Ruby was well connected with MySQL lead to the following errors (both errors came repeatedly during my way to the solution, given below…):

  • uninitialized constant MysqlCompat::MysqlRes
  • dyld: lazy symbol binding failed: Symbol not found: _mysql_init
    Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/
    mysql.bundle

After some research and tests following different articles on the net, I finally got with a working solution (however please notice that it applies to an Intel Mac with 64bits processor under Snow Leopard):

  • Install the latest x86_64 MySQL release (currently the mysql-5.1.53-osx10.6-x86_64). Several articles on the net will tell you the problems are due to the 64 bits version, you should install the 32 bits one, and so on. In my case, I tried both and it worked with the 64 bits one.
  • Make it work! Check the install documentation, connect with mysql, start the server… to be sure everything is working. A good thing would be to be able to connect to it with phpMyAdmin for example (which I did).
  • If you had already install the mysql gem (which you should have to need this page because you must have faced the previously mentioned issues…), uninstall it with sudo gem uninstall mysql.
  • The trick is then to reinstall it with the following command line: sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config which ensures the gem is installed for the 64bits architecture, matching the MySQL one.

Then, you should not face the previous problem any more, maybe some access denials due to misconfiguration in your RoR’s project “database.yml” file or your MySQL configuration. But the Ruby/MySQL connection should be OK!

Advertisements
Categories: Mac OS X Tips Tags: , , , , ,
  1. Sylvain
    24/11/2010 at 8:43 pm

    There is the same kind of issue on Windows. Thanks for sharing because I switch to Mac in January and I don’t try ROR 3 yet.

    • rchampourlier
      25/11/2010 at 7:27 am

      Pleased to help 😉 Don’t hesitate to come back if you’re facing a problem even with this tip, I may help and that would allow me to complete it 😉 How’s California?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: