Failing to bundle install tiny_tds on Mac OS X 10.8 with Homebrew FreeTds

freetds, macos, ruby, ruby-on-rails, tiny-tds

Solution

Well, unfortunately I've now got it working and have NO CLUE how I've done it but I will list all of the things I've done so far in this answer to solve it.

In the end, `bundle install` with standard `gem 'tiny_tds', '0.5.1'` ended up working fine. It's running Ruby version 1.9.3-p194 via RVM.

This is where the gold is I'm fairly sure... I used `rvm pkg install iconv` and `rvm reinstall 1.9.3 --with-iconv-dir=$rvm_path/usr`

Once this completed, I deleted all old gem folders... I switched bundle config path to match the new ruby path...

Then did bundle install, and boom.

It's also using iconv 1.13 instead of 1.14 not sure if that matters.

I hope this helps anyone... it's definitely been a huge learning experience for me.

Problem

MY QUESTION What are some surefire steps I can take to 100% get this working? I would need real instructions, not one liner answers or vague conceptual descriptions of the process. Let's get to the bottom of this. It would appear that there are conflicts somewhere and I've had subpar assistance from the gem developer on GitHub in relation to my experience with Ruby / Rails / Bundler / Homebrew so it's not completely their fault :P But I need to figure out how to get this working ASAP so here goes with my current state of this problem. UPDATE: 2/25/2013 Updated GCC / XCODE Version 4.6 (4H127) and downloaded latest version of XCODE COMMAND-LINE TOOLS and now iconv_open() is showing up in the extconf checker. Now I'm getting these errors: I believe they are now issues with tiny_tds and compatibility with latest xcode paths. ``` Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb checking for iconv_open() in iconv.h... yes checking for sybfront.h... yes checking for sybdb.h... yes checking for tdsdbopen() in -lsybdb... yes checking for ct_bind() in -lct... yes creating Makefile make xcrun cc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -DHAVE_ICONV_OPEN -DHAVE_SYBFRONT_H -DHAVE_SYBDB_H -I-I/usr/local/php5/include -I-I/usr/include -I-I/usr/local/include -I-I/opt/local/include -I-I/usr/local/MacGPG2/include -I-I/opt/sm/pkg/active/include -I/usr/local/php5/include -I/usr/include -I/usr/local/include -I/opt/local/include -I/usr/local/MacGPG2/include -I/opt/sm/pkg/active/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c client.c xcrun: Error: could not stat active Xcode path '/Developer'. (No such file or directory) xcrun cc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -DHAVE_ICONV_OPEN -DHAVE_SYBFRONT_H -DHAVE_SYBDB_H -I-I/usr/local/php5/include -I-I/usr/include -I-I/usr/local/include -I-I/opt/local/include -I-I/usr/local/MacGPG2/include -I-I/opt/sm/pkg/active/include -I/usr/local/php5/include -I/usr/include -I/usr/local/include -I/opt/local/include -I/usr/local/MacGPG2/include -I/opt/sm/pkg/active/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c result.c xcrun: Error: could not stat active Xcode path '/Developer'. (No such file or directory) xcrun cc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin12.0 -I. -DHAVE_ICONV_OPEN -DHAVE_SYBFRONT_H -DHAVE_SYBDB_H -I-I/usr/local/php5/include -I-I/usr/include -I-I/usr/local/include -I-I/opt/local/include -I-I/usr/local/MacGPG2/include -I-I/opt/sm/pkg/active/include -I/usr/local/php5/include -I/usr/include -I/usr/local/include -I/opt/local/include -I/usr/local/MacGPG2/include -I/opt/sm/pkg/active/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -g -Os -pipe -fno-common -DENABLE_DTRACE -fno-common -pipe -fno-common -c tiny_tds_ext.c xcrun: Error: could not stat active Xcode path '/Developer'. (No such file or directory) cc -pipe -bundle -undefined dynamic_lookup -o tiny_tds.bundle client.o result.o tiny_tds_ext.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L/usr/local/heroku/lib -L/usr/local/php5/lib -L/usr/local/Cellar/ruby/1.9.3-p194/lib -L/usr/lib -L/usr/local/lib -L/opt/local/lib -L/usr/local/MacGPG2/lib -L/opt/sm/pkg/active/lib -L/Users/rountrjf/.rvm/lib -L/usr/local/Cellar/vertx/lib -L/usr/local/Cellar/vertx/mods/node.vert.x/lib -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -lruby -lct -lsybdb -lpthread -ldl -lobjc i686-apple-darwin11-llvm-gcc-4.2: client.o: No such file or directory i686-apple-darwin11-llvm-gcc-4.2: result.o: No such file or directory i686-apple-darwin11-llvm-gcc-4.2: tiny_tds_ext.o: No such file or directory make: *** [tiny_tds.bundle] Error 1 Alright, since /Developer doesn't exist. I used `sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer` thinking that would fix it. Now I'm back to square one... iconv_open() not found when checked with `extconf.rb` ``` UPDATE 2: 2/25/2013 OKAY, so I reinstalled everything, Ruby / Rails / etc. And used some advice from a commenter to use ":path =>" and here is my output now when I run `rails s` ``` /Users/rountrjf/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- tiny_tds (LoadError) from /Users/rountrjf/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `block in require' from /Users/rountrjf/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency' from /Users/rountrjf/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require' from /Users/rountrjf/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-sqlserver-adapter-3.2.10/lib/active_record/connection_adapters/sqlserver_adapter.rb:31:in `sqlserver_connection' from /Users/rountrjf/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection' ``` THINGS I'VE TRIED 1.) The initial EASY setup instructions like any other... ``` $ rails new test_app $ cd test_app ``` Now add these lines to `Gemfile` ``` gem 'tiny_tds' gem 'activerecord-sqlserver-adapter' ``` Now continue commands... ``` $ bundle install Fetching gem metadata from https://rubygems.org/........... Fetching gem metadata from https://rubygems.org/.. Resolving dependencies... Using rake (10.0.3) Using i18n (0.6.1) Using multi_json (1.6.1) Using activesupport (3.2.12) Using builder (3.0.4) Using activemodel (3.2.12) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.5) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.2.2) Using actionpack (3.2.12) Using mime-types (1.21) Using polyglot (0.3.3) Using treetop (1.4.12) Using mail (2.4.4) Using actionmailer (3.2.12) Using arel (3.0.2) Using tzinfo (0.3.35) Using activerecord (3.2.12) Using activerecord-sqlserver-adapter (3.2.10) Using activeresource (3.2.12) Using bundler (1.2.4) Using coffee-script-source (1.4.0) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.7.7) Using rdoc (3.12.1) Using thor (0.17.0) Using railties (3.2.12) Using coffee-rails (3.2.2) Using jquery-rails (2.2.1) Using rails (3.2.12) Using sass (3.2.5) Using sass-rails (3.2.6) Installing tiny_tds (0.5.1) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/Cellar/ruby/1.9.3-p194/bin/ruby extconf.rb checking for iconv_open() in iconv.h... no checking for iconv_open() in -liconv... no ----- libiconv 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=/usr/local/Cellar/ruby/1.9.3-p194/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}/lib --with-freetds-dir --without-freetds-dir --with-freetds-include --without-freetds-include=${freetds-dir}/include --with-freetds-lib --without-freetds-lib=${freetds-dir}/lib --with-iconvlib --without-iconvlib Gem files will remain installed in /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/gems/tiny_tds-0.5.1 for inspection. Results logged to /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/gems/tiny_tds-0.5.1/ext/tiny_tds/gem_make.out An error occurred while installing tiny_tds (0.5.1), and Bundler cannot continue. Make sure that `gem install tiny_tds -v '0.5.1'` succeeds before bundling. ``` OUTPUT OF `tsql -C` ``` $ tsql -C Compile-time settings (established with the "configure" script) Version: freetds v0.91 freetds.conf directory: /usr/local/Cellar/freetds/0.91/etc MS db-lib source compatibility: no Sybase binary compatibility: no Thread safety: yes iconv library: yes TDS version: 7.1 iODBC: yes unixodbc: no SSPI "trusted" logins: no Kerberos: no ``` 2.) IMAGINARY SUCCESS / FAKE IT TIL YOU MAKE IT / A BIG LET DOWN / ADVANCED SETUP INSTRUCTIONS Found this blog entry... http://talltroym.blogspot.com/2012/04/installing-activerecord-sqlserver.html I then located my correct paths to the libiconv library and the freetds library. Next, I ran it like this: ``` $ sudo gem install tiny_tds -- --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib --with-freetds-lib=/usr/local/Cellar/freetds/0.91/lib --with-freetds-include=/usr/local/Cellar/freetds/0.91/include Password: Building native extensions. This could take a while... Successfully installed tiny_tds-0.5.1 1 gem installed Installing ri documentation for tiny_tds-0.5.1... Installing RDoc documentation for tiny_tds-0.5.1... ``` Tried `bundle_install` again, and shock... it still isn't installing via `gem 'tiny_tds'` in Gemfile... So I remove tiny_tds from Gemfile and proceed to start the server up anyway... And as expected... ``` $ rails s => Booting WEBrick => Rails 3.2.12 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- tiny_tds (LoadError) ... ``` 3.) MINI PORTILE ``` $ sudo gem install mini_portile $ sudo gem install rakecompiler $ rake TINYTDS_FREETDS_VERSION="current" Could not find gem 'tiny_tds (>= 0) ruby' in the gems available on this machine. Run `bundle install` to install missing gems. ``` OTHER RELATED QUESTIONS AND RESOURCES - Error installing TinyTDS on OSX 10.6 via gem install tiny_tds (not informative at all... due to the fact that it isn't working for me at all.) - FreeTDS Mac OS X MiniPortile (Not very informative on the approach of miniportile or how to use it...) - Homebrew / TinyTDS / FreeTDS bundle error (relates to linux, not Mac) - ROR + Unable to install tiny_tds - http://talltroym.blogspot.com/2012/04/installing-activerecord-sqlserver.html (a blog entry that gave me false hope) - https://github.com/rails-sqlserver/tiny_tds/issues/71 (github issue I commented in where I received some advise that I didn't understand well enough to translate into a success story) - https://github.com/rails-sqlserver/tiny_tds (github for tiny_tds gem)

Original source

Related problems