ROR FreeTDS在OSX上安装失败

时间:2015-03-19 20:25:49

标签: ruby-on-rails sql-server macos freetds

下午好,我正在尝试使用带有Ruby on Rails的MS SQL Server数据库。根据我的研究,我已经安装了FreeTDS和unixodbc,然后再将它添加到我的Rails项目中。我已经测试了我的安装并连接/查询了许多MSSQL数据库中没有问题:

$ 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>;

..结果跟随..

成功运行测试后,我决定尝试为我的新Rails应用程序捆绑安装。我修改了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'
...

当我运行bundle install时,出现以下错误:

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.

我已阅读其他相关帖子,包括ROR + Unable to install tiny_tds,但是,这些答案仅反映了指向我已经验证的工作的一般答案。我找到了FreeTDS here的构建/配置标志参考:

  

- enable-dbmfix:将dbopen()重命名为tdsdbopen()作为解决dbm名称冲突的方法

所以,我的最终问题是,是否有人可以告诉我这是否可以在配置文件中完成,或者我必须构建我自己的FreeTDS版本来解决这个问题?

1 个答案:

答案 0 :(得分:0)

好的,在花了更多时间搜索其他经验之后,我发现了一个模糊的32位与64位FreeTDS版本的引用。这可以通过强制指定64位版本来解决:

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

Ran捆绑安装,一切正常。