问题描述: 在安装SQL Adapter和Tiny_tds Gem时,可能会遇到以下错误信息:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
...
checking for hiredis/hiredis.h... no
*** 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.
并且在执行bundle install
命令时,可能会看到类似以下的错误警告信息:
WARN: Unresolved specs during Gem::Specification.reset:
hiredis (>= 0.4.5, ~> 0.4)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
解决方法: 这个问题通常是由于缺少hiredis扩展库引起的。下面是解决方法:
确保已安装hiredis扩展库。
sudo apt-get install libhiredis-dev
brew install hiredis
重新安装SQL Adapter和Tiny_tds Gem。
gem 'activerecord-sqlserver-adapter', '~> 6.0'
gem 'tiny_tds', '~> 2.1'
保存并关闭Gemfile文件。
在终端中运行以下命令重新安装Gem:
bundle install
bundle clean --force
bundle install
命令,应该就能成功安装SQL Adapter和Tiny_tds Gem了。验证Gem是否成功安装。
bundle exec rails c
希望以上解决方法能帮助到你解决问题!