Monday, June 20, 2011

Giving gem options to bundler install.

As I work more with ArchLinux...  I discovered bundler config options.

For gherkin it seems I need to do this:
gem install gherkin -- --with-cflags="-std=c99"

Yet, in bundler it's not obvious how to pass these along.  You can't do it in the Gemfile -- and you might not want to since another machine could have a different environment.

To pass these flags you create a configuration for the build, which is stored in your machines config only.

From Bundler Gemfile docs:


You can use bundle config to give bundler the flags to pass to the gem installer every time bundler tries to install a particular gem.
A very common example, the mysql gem, requires Snow Leopard users to pass configuration flags to gem install to specify where to find themysql_config executable.
gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Since the specific location of that executable can change from machine to machine, you can specify these flags on a per-machine basis.
bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
After running this command, every time bundler needs to install themysql gem, it will pass along the flags you specified.

First spotted here:

1 comment: