Rails 4: Ошибка при установке tiny_tds gem?
Я разработал веб-проект rails с Ruby v2 и Rails v4. Он отлично работал в моей текущей системе, и когда я пытался запустить этот проект на другой машине 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 seperatly, но все же я получаю ту же проблему
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'
Почему возникает эта ошибка и как решить эту проблему.
Любая помощь приветствуется
Ответы
Ответ 1
Похоже, на вашем компьютере не установлены freetds:
sudo apt-get install freetds-dev
Если вы видите детали freetds-dev, вы увидите, что у него отсутствует файл sybfront.h
Нет никакого драгоценного камня, который я знаю для freetds
, и для создания драгоценного камня tiny_tds
требуется его компиляция. Однако вы можете создать свою собственную версию драгоценного камня, используя MiniPortile
.
Вместо использования обычного механизма gem install
вам нужно клонировать tiny_tds
из GitHub, а затем построить собственный камень для вашей среды. Этот процесс будет включать загрузку конкретной версии freetds
, которая используется для компиляции драгоценного камня.
Это должно помочь вам решить проблему неспособности установить пакет freetds-dev
, но имеет тот недостаток, что при обновлении tiny_tds
gem в будущем вам нужно будет повторять этот процесс каждый раз - вы можете " t просто воспользуйтесь bundle update
.
Ниже вы найдете подробные здесь.
Ответ 2
Это работало для меня в 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
Разархивировать
$ tar -xzf 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 install tiny_tds -v '2.0.0'
Если вы все еще не можете установить gem tiny_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
Ответ 3
Для MacOS вам нужна дополнительная библиотека.
brew install freetds