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. 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?).
# WARN: this doesn't work with latest bundler gem. Read on for proper instructions $ gem bundle --build-options build_options.yml
After looping for a bit, I finally ended up at the right place (Google found this on gembundler.com but there is no way to get to this from the website itself). 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