[Rails][AzureSQLデータベース]Macでtiny_tdsのbundle installが通らない時の対処法

  • 4
    Like
  • 0
    Comment
More than 1 year has passed since last update.

AzureSQLデータベースを使うときにtiny_tdsというGemをインストールするときにコケたのでメモ。

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /Users/username/.rbenv/versions/2.0.0-p247/bin/ruby extconf.rb
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for sybfront.h... no
-----
freetds is missing.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/username/.rbenv/versions/2.0.0-p247/bin/ruby
    --enable-lookup
    --disable-lookup
    --with-iconv-dir
    --without-iconv-dir
    --with-iconv-include
    --without-iconv-include=${iconv-dir}/include
    --with-iconv-lib
    --without-iconv-lib=${iconv-dir}/
    --with-freetds-dir
    --without-freetds-dir
    --with-freetds-include
    --without-freetds-include=${freetds-dir}/include
    --with-freetds-lib
    --without-freetds-lib=${freetds-dir}/
    --with-iconvlib
    --without-iconvlib


Gem files will remain installed in /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/tiny_tds-0.6.1 for inspection.
Results logged to /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/tiny_tds-0.6.1/ext/tiny_tds/gem_make.out

An error occurred while installing tiny_tds (0.6.1), and Bundler cannot continue.
Make sure that `gem install tiny_tds -v '0.6.1'` succeeds before bundling.

色々試行錯誤しても同様のエラーが出続けてたのでgithubを覗いてみる

https://github.com/rails-sqlserver/tiny_tds#install

書いてあった!

tiny_tdsはFreeTDSっていうライブラリを先に入れておかないといけないらしい。
ちゃんと読めよっていう。

$ brew install freetds
でFreeTDSをインストール

最後にbundle installで完了。