meaning of "it"

Installing mysql gem with bundler on Snow Leopard

with 2 comments

Between 0.9.26, RC and final 1.0 release, bundler went thru some heavy changes with respect to command line options it supports. Luckily, twitter, forum and blogs kept everybody in the loop.

The blogs, however, became obsolete quickly and even blog posts few months old don’t work with latest version of bundler. We came across this issue that kept is in a loop for a while.

Snow Leopard changed a few things with ruby and mysql gem when it came out. Most mysql installation issues are hammered out by now and are well documented.

Before you jump and execute following commands, make sure that you indeed have 64 bit mysql and 64 bit ruby on your machine. (If not, these instructions may not apply to your need).

$ file `which ruby`
/Users/xxx/ruby/bin/ruby: Mach-O 64-bit executable x86_64
$ file `which mysql`
/usr/local/mysql/bin/mysql: Mach-O 64-bit executable x86_64

Both installations should be Mach-O 64-bit x86_64 architecture.

In summary, installing mysql gem requires 2 things:

  • Specifying architecture flags: ARCHFLAGS=”-arch x86_64″
  • Specify location of mysql_config to compile agains: –with-mysql-config=/usr/local/mysql/bin/mysql_config

Prior to bundler, this is what you would do on snow-leopard to install mysql:

$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

With bundler, there is no command line option that I could find that I can pass to “bundle install” command. Having been in the loop around bundler, I knew that such OS specific options don’t go in Gemfile and have to be specified in user specific files such as ~/.bundle/config file. The official website for gem-bundler doesn’t have any mention of this (is it because we need to keep things simple for people just getting upto speed with bundler?).

Bundler has a feature which allow specifying build options as documented here. So, I did this:

$ bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

This updated my ~/.bundle/config with proper information that it will need for “bundle install” command. It make sense to keep this in ~/ folder and not my project folder since it applies only to my environment and it applies to all projects on this machine.

With this, doing “bundle install” still doesn’t install mysql properly. Comparing this to the pre-bundler command, it solves one issue. The ARCHFLAGS still need to be available for “bundle install”. With some leap of faith, I set an environment variable to this effect:

$ export ARCHFLAGS="-arch x86_64"
# should this go in my .bash_profile (so that mysql installs fine always, for all projects?
# And I don't have to remember to set this each time I do a fresh bundle install.

And voila, “bundle install” installs mysql correctly.

Bundler is stable now and is making everybody’s life much much easier. It isn’t changing as fast and so this blog post won’t be obsolete too soon ;)

http://www.tatvartha.com/wp-content/plugins/sociofluid/images/digg_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/reddit_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/stumbleupon_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/delicious_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/google_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/twitter_16.png

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Written by Sharad

October 7th, 2010 at 6:34 pm

Posted in All

Tagged with , , , , ,

2 Responses to 'Installing mysql gem with bundler on Snow Leopard'

Subscribe to comments with RSS or TrackBack to 'Installing mysql gem with bundler on Snow Leopard'.

  1. thanks, solved my problem :)
    i just wonder… now my local setup works perfectly, but what will happen when i will run bundle install on the production server? bad feeling about that… :)


    23 May 11 at 3:34 am

  2. Cool it worked for me. Thanks


    3 Jun 11 at 10:04 am

Leave a Reply