2

Good afternoon, I am trying to utilize a MS SQL Server DB with Ruby on Rails. Based on my research, I've installed FreeTDS and unixodbc before proceeding to add it to my Rails project. I've tested my install and connected/queried any of many MSSQL databases without issue:

$ sqsh -S <servername> -U <username>
sqsh-2.5.16.1 Copyright (C) 1995-2001 Scott C. Gray
Portions Copyright (C) 2004-2014 Michael Peppler and Martin Wesdorp
This is free software with ABSOLUTELY NO WARRANTY
For more information type '\warranty'
Password: 
[4] <server>.master.1> use <DBNAME>;
[5] <server>.<DBNAME>.1> select top 5 * from <tablename>;

.. results follow ..

After a successful run of tests, I decided to try and bundle install for my new Rails app. I modified the gemfile:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use MS SQL Server as the database for Active Record
# and default connection through tiny_tds default connection mode
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
...

When I run bundle install, I get the following error:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb 
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for sybfront.h... yes
checking for sybdb.h... yes
checking for tdsdbopen() in -lsybdb... 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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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
    --with-sybdblib
    --without-sybdblib


Gem files will remain installed in /var/folders/vh/3f8srsrs57zbk6p7vg7fg6pw0000gn/T/bundler20150319-18359-ed8ld7/tiny_tds-0.6.2/gems/tiny_tds-0.6.2 for inspection.
Results logged to /var/folders/vh/3f8srsrs57zbk6p7vg7fg6pw0000gn/T/bundler20150319-18359-ed8ld7/tiny_tds-0.6.2/gems/tiny_tds-0.6.2/ext/tiny_tds/gem_make.out
An error occurred while installing tiny_tds (0.6.2), and Bundler cannot continue.
Make sure that `gem install tiny_tds -v '0.6.2'` succeeds before bundling.

I've read through other related posts on SO including ROR + Unable to install tiny_tds, however, those answers only reflect generic answers pointing to work that I've already validated. I found a build/config flag reference for FreeTDS here:

--enable-dbmfix: rename dbopen() to tdsdbopen() as a work around for dbm name conflict

So, my ultimate question is whether anybody can tell me whether this can be done in config file somewhere or that I have to build my own version of FreeTDS to solve this?

Community
  • 1
  • 1
the Craig
  • 21
  • 3

1 Answers1

0

OK, after spending more time searching through other experiences, I found an obscure reference to 32-bit vs. 64-bit versions of FreeTDS. This can be resolved through forcing specification of 64-bit version:

$ sudo ARCHFLAGS="-arch x86_64" gem install tiny_tds

Ran bundle install and everything works.

the Craig
  • 21
  • 3