unable to install recommendify gem - hiredis.h not found

1.9k views Asked by At

I am trying to install recommendify gem.

This gem try to compile a native bin called recommendify to be faster than ruby´s parser.

First i tried to install like other common gem:

gem install recommendify

and this is the error:

➜  ~  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

Second, i installed hiredis with brew:

brew install hiredis

and now if i search hiredis i can see:

➜  ~  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

In my path is included '/usr/local/include' -> the directory when is installed 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

Any idea? Thanks in advance

EDIT 1 *

I have tried with the solution of the first answer:

gem install recommendify -- --with-hiredis-dir=/usr/local/Cellar/hiredis/0.11.0

and also:

gem install recommendify -- --with-hiredis-dir=/usr/local/Cellar/hiredis/0.11.0/include/hiredis

Having in both the same error:

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

EDIT 2 *

I have reinstalled xcode, line-command-tools and ruby with rbenv and the problem is solved. I dont know which of this three element was the problem but now it works :D

Thanks to everyone

2

There are 2 answers

5
Aleksei Matiushkin On

Some of gems are pure ruby, while others (mostly platform specific linking against existing c/c++ libraries, e. g. bindings) are written in both ruby and c/c++. The part, written in c/c++ is called native extensions. To compile them you need:

  • build tools;
  • ruby development environment;
  • additional libraries/headers required by this specific gem.

In your case you seem to have first two requirements satisfied, while your system is unable to locate development files for hiredis. The summing up:

gem install recommendify -- --with-hiredis-dir=/usr/local/Cellar/hiredis/0.11.0

should resolve the issue.

Hope this helps.

0
Nathan Bertram On

On ubuntu I was able to get this gem install after installing libpq-dev

sudo apt-get install libpq-dev