Ruby on rails Rails 4:安装tiny_tds gem时出错?

Ruby on rails Rails 4:安装tiny_tds gem时出错?,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,我用Ruby v2和rails v4开发了一个rails web项目。它在我当前的系统中工作得非常好,当我试图在另一台Linux机器(Ubuntu12.4)上运行这个项目时,我得到了一个整洁的tds错误 此错误在安装捆绑包时显示 错误详细信息如下 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

我用Ruby v2和rails v4开发了一个rails web项目。它在我当前的系统中工作得非常好,当我试图在另一台Linux机器(Ubuntu12.4)上运行这个项目时,我得到了一个整洁的tds错误

此错误在安装捆绑包时显示

错误详细信息如下

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.                                                                                                                                

    /home/action/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb                                                                                                                                       
checking for iconv_open() in iconv.h... yes                                                                                                                                                       
checking for sybfront.h... no                                                                                                                                                                     
-----                                                                                                                                                                                             
freetds is missing.    
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-lib=${opt-dir}/lib                                                                                                                                                          
        --with-make-prog                                                                                                                                                                          
        --without-make-prog                                                                                                                                                                       
        --srcdir=.                                                                                                                                                                                
        --curdir                                                                                                                                                                                  
        --ruby=/home/action/.rvm/rubies/ruby-2.1.1/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                                                                                                                                                  

extconf failed, exit code 1      
Gem files will remain installed in /home/action/.rvm/gems/ruby-2.1.1/gems/tiny_tds-0.6.1 for inspection.                                                                                          
Results logged to /home/action/.rvm/gems/ruby-2.1.1/extensions/x86_64-linux/2.1.0/tiny_tds-0.6.1/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. 
我也尝试过单独安装tiny_tds,但仍然遇到同样的问题

gem install tiny_tds -v '0.6.1'
我的宝石档案

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
gem 'tiny_tds' 
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

gem 'jquery-ui-rails' # jquery ui

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use sqlserver as the database for Active Record
gem 'activerecord-sqlserver-adapter', :git => 'https://github.com/nextgearcapital/activerecord-sqlserver-adapter.git'
gem "therubyracer"
gem "less-rails" 
gem "twitter-bootstrap-rails"
gem 'bootstrap-datepicker-rails'
gem 'will_paginate'
gem 'sqlite3'
gem 'formtastic'
为什么会出现此错误以及如何解决此问题


非常感谢您的帮助

您的计算机上似乎没有安装freetds:

sudo apt-get install freetds-dev
如果您看到软件包的详细信息,您将看到它缺少文件
sybfront.h

我所知道的
freetds
没有gem,构建
tiny_tds
gem需要编译它。但是,您应该可以使用
MiniPortile
构建自己的gem版本

您需要从GitHub克隆
tiny_tds
,然后为您的环境构建本机gem,而不是使用正常的
gem安装
机制。此过程将包括下载特定版本的
freetds
,该版本用于编译gem

这应该可以解决无法安装
freetds-dev
软件包的问题,但它的缺点是,如果
tiny\u-tds
gem在将来更新,您将需要每次重复此过程-您不能简单地利用
bundle-update


您需要遵循的步骤非常详细。

这在
Ubuntu 17.04中对我很有效

安装
wget
从远程URL下载软件包

$ sudo apt-get install wget 
安装依赖项

$ sudo apt-get install build-essential
$ sudo apt-get install libc6-dev
下载远程文件

$ wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.00.21.tar.gz
解压

为系统中的包配置并运行测试

$ cd freetds-1.00.21
$ sudo ./configure --prefix=/usr/local --with-tdsver=7.3
$ sudo make
现在,安装

$ sudo make install
现在安装gem

$ gem install tiny_tds -v '2.0.0'
如果仍然无法安装gem
tiny\u tds
,请尝试使用sudo
$sudo gem install tiny_tds-v'2.0.0'

输出

Building native extensions.  This could take a while...
Successfully installed tiny_tds-2.0.0
Parsing documentation for tiny_tds-2.0.0
Installing ri documentation for tiny_tds-2.0.0
Done installing documentation for tiny_tds after 1 seconds
1 gem installed

对于MacOS,您需要安装额外的lib

brew install freetds

谢谢你提供的信息。是否可以将freetds安装为gem,因为我正在尝试在一个我没有管理员权限的VM中设置我的项目。很高兴我能提供帮助:)在fedora上,在Mac上执行
sudo yum安装freetds devel
,执行
brew安装freetds
谢谢。当我运行
sudo make
时,我得到一个
/freetds-1.00.21/missing autoconf
。如果我5个月后弄清楚的话,我会报告的<代码>sudo apt get install autoconf
修复了该问题
sudomake
sudomake安装现在可以工作了。我有
tiny\u tds
在WSL(Linux的Windows子系统)上工作。太高兴了!
brew install freetds