Install TinyTDS Gem on OSX 10.10 Yosemite

with tags ruby rails -

There are a couple of howtos out there on how to fix the dreaded ERROR: Failed to build gem native extension. when running gem install tiny_tds.

This one will fix it without having to force link libiconv which is not a good thing to do.


First you want to make sure that you have freetds and libiconv installed in Homebrew. I already had these installed so YMMV on this step:

brew install libiconv
brew install freetds

It is normal for libiconv to complain that it is keg only, that is the whole point.

Install tiny_tds

Now it is just a simply matter of telling gem install where libiconv and freetds are located.

$ gem install tiny_tds -- --with-iconv-dir=$(brew --prefix libiconv) \
  --with-freetds-dir=$(brew --prefix freetds)
Building native extensions.  This could take a while...
Successfully installed tiny_tds-0.6.2
1 gem installed

IMPORTANT: Do not forget the double hyphen (--) between the gem install command and the options.