我正在尝试安装推荐宝石。
这个 gem 尝试编译一个名为 Recommendationify 的本地 bin,以比 ruby 的解析器更快。
首先,我尝试像其他常见的 gem 一样安装:
gem install recommendify
这是错误:
➜ ~ gem install recommendify
Building native extensions. This could take a while...
ERROR: Error installing recommendify:
ERROR: Failed to build gem native extension.
/Users/villa/.rbenv/versions/1.9.3-p448/bin/ruby extconf.rb
make mkdir -p ../bin
gcc -Wall recommendify.c -lhiredis -o ../bin/recommendify
recommendify.c:4:10: fatal error: 'hiredis/hiredis.h' file not found
#include <hiredis/hiredis.h>
^
1 error generated.
make: *** [build] Error 1
其次,我用brew安装了hiredis:
brew install hiredis
现在如果我搜索hiredis,我可以看到:
➜ ~ brew list hiredis
/usr/local/Cellar/hiredis/0.11.0/include/hiredis/ (5 files)
/usr/local/Cellar/hiredis/0.11.0/lib/libhiredis.0.10.dylib
/usr/local/Cellar/hiredis/0.11.0/lib/ (3 other files)
➜ ~ find /usr/local/include -name hiredis
/usr/local/include/hiredis
➜ ~ ls -al /usr/local/include/hiredis
lrwxr-xr-x 1 villa admin 40 15 dic 12:54 /usr/local/include/hiredis -> ../Cellar/hiredis/0.11.0/include/hiredis
在我的路径中包含'/usr/local/include' - >安装hiredis时的目录:
➜ ~ echo $PATH
/usr/local/include:/Users/villa/.rbenv/shims:/usr/local/Cellar/elixir/0.10.3/bin:/Users/villa/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
任何想法?提前致谢
编辑 1 *
我已经尝试过第一个答案的解决方案:
gem install recommendify -- --with-hiredis-dir=/usr/local/Cellar/hiredis/0.11.0
并且:
gem install recommendify -- --with-hiredis-dir=/usr/local/Cellar/hiredis/0.11.0/include/hiredis
有两个相同的错误:
Building native extensions. This could take a while...
ERROR: Error installing recommendify:
ERROR: Failed to build gem native extension.
/Users/villa/.rbenv/versions/1.9.3-p448/bin/ruby extconf.rb --with-hiredis-dir=/usr/local/include/hiredis
make
mkdir -p ../bin
gcc -Wall recommendify.c -lhiredis -o ../bin/recommendify
recommendify.c:4:10: fatal error: 'hiredis/hiredis.h' file not found
#include <hiredis/hiredis.h>
^
1 error generated.
make: *** [build] Error 1
编辑 2 *
我已经用 rbenv 重新安装了 xcode、line-command-tools 和 ruby,问题就解决了。我不知道这三个元素中的哪一个是问题,但现在它可以工作了:D
谢谢大家