rails6 tiny_tdsインストール時にエラー「An error occurred while installing tiny_tds (2.1.3), and Bundler cannot continue.」が発生

rails6 tiny_tdsインストール時にエラー「An error occurred while installing tiny_tds (2.1.3), and Bundler cannot continue.」が発生

rails6でtiny_tdsインストール時にエラー「An error occurred while installing tiny_tds (2.1.3), and Bundler cannot continue.」が発生した原因と対処法を記述してます。Railsのバージョンは6.1.1を使用してます。

環境

  • OS CentOS Linux release 7.9.2009 (Core)
  • Ruby 2.7.2
  • Rails 6.1.1
  • rbenv 1.1.2-40-g62d7798

エラー全文

Gemfileに以下を記述して「bundle install」実行時に発生

gem 'tiny_tds'

エラー全文

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/sampleuser/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/tiny_tds-2.1.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/sampleuser/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/tiny_tds-2.1.3 for inspection.
Results logged to /home/sampleuser/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/tiny_tds-2.1.3/gem_make.out

An error occurred while installing tiny_tds (2.1.3), and Bundler cannot continue.
Make sure that `gem install tiny_tds -v '2.1.3' --source 'https://rubygems.org/'` succeeds before bundling.

原因

sqlserverの開発ツールをインストールする必要があるようです。

対処法

インストールを行います。

sudo yum install freetds-devel