2014-08-28 129 views
0

我們正在使用適用於Rails 4的activerecord-sqlserver-adapter適配器來與SQL Server數據庫進行通信。此適配器需要使用tiny_tds寶石。爲了安裝tiny_tds,您需要在您的系統上安裝freetds,因爲它是在編譯gem時使用的。Mac,Rails 4:使用`freetds`安裝`tiny_tds` gem

在我的系統上,我安裝了RVM和自制軟件。我有brew install freetds,並確認它的工作原理是tsql -C,並且實際上已連接到SQL Server。根據我的理解,這意味着freetds已「安裝」在我的機器上並正常工作。

然而,每次我做一個gem install tiny_tds如果抱怨freetds is missing

我嘗試了好幾種的「連接」到適當的文件,但似乎沒有爲我工作的參數選項。我已經花了幾個小時搜索並查看寶石作者的着作。我正在使用的其他一些開發人員具有此功能,但我正在設置一個新環境,並且出於某種原因無法使其工作。他們已經研究過它,但不確定問題是什麼。

看來,安裝的tiny_tds寶石只是不知道freetds實際上安裝在系統上。

在一個旁註中,我也看過mini_portile,它也不能正常工作,因爲我已經花了幾個小時在當前路徑下,我想在切換到之前解決這個問題調查mini_portile

下面是安裝的輸出:

$ gem install tiny_tds 
Building native extensions. This could take a while... 
ERROR: Error installing tiny_tds: 
    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 /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2 for inspection. 
Results logged to /Library/Ruby/Gems/2.0.0/gems/tiny_tds-0.6.2/ext/tiny_tds/gem_make.out 

回答

0

終於解決了這一點。在安裝RVM之後,忘記了通過RVM安裝Ruby,這導致了所有問題。

如果您發現與上述類似的奇怪錯誤,請執行rvm list以查看是否已安裝任何Rubies,然後在終端(Mac)上執行which ruby以查看您是否確實在使用RVM Ruby。