ruby-on-rails - rails 4 : Error when installing tiny_tds gem?

标签 ruby-on-rails ruby ruby-on-rails-4

我使用 Ruby v2 和 Rails v4 开发了一个 Rails Web 项目。它在我当前的系统中运行良好,当我尝试在另一台 Linux 机器 (Ubuntu 12.4) 中运行该项目时,出现 Tidy_tds 错误。

此错误在 bundle install 时显示,

错误详情如下

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'

我的 gem 文件,

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

如果您看到 freetds-dev 的详细信息包你会看到它有丢失的文件 sybfront.h

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

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

这应该可以解决无法安装 freetds-dev 包的问题,​​但如果 tiny_tds gem 将来更新,则确实存在缺点每次都需要重复此过程 - 您不能简单地利用 bundle update

需要遵循的步骤很详细here .

关于ruby-on-rails - rails 4 : Error when installing tiny_tds gem?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23593086/

相关文章:

ruby-on-rails - 本地 postgres 数据库不断给出错误 duplicate key value violates unique constraint

ruby-on-rails - 如何用管道分隔打印哈希值

arrays - 匹配数组中的子串

java - 使用本地电话调制解调器作为短信网关从 php 发送短信

ruby-on-rails - 如何通过 has_many 关系的属性之和来过滤模型

ruby-on-rails - Rails 4.2 如何计算指纹摘要

ruby-on-rails - 工头立即终止

ruby-on-rails - 没有端口号的 Rails 应用程序

ruby-on-rails - rails : can I use elasticsearch-model and active_model_serializers together?

ruby-on-rails - 如何在 Rails 测试中断言图像源