jemc / ruby-rabbitmq

A Ruby RabbitMQ client library based on FFI bindings for librabbitmq. :gem: :rabbit2:
MIT License
10 stars 7 forks source link

Error installing on MRI 2.3+ #6

Open janko opened 7 years ago

janko commented 7 years ago

I get the following error when I try to gem install rabbitmq on MRI 2.3 or 2.4:

librabbitmq/amqp_openssl.c:39:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
         ^~~~~~~~~~~~~~~~

Here is the full error log: https://gist.github.com/janko-m/2ae7441b0610f01baddbcdb00709c930

janko commented 7 years ago

I only get that on my local Mac OS computer, it's not happening on Ubuntu.

jemc commented 7 years ago

@janko-m Does openssl/conf.h exist anywhere on your machine (being a search path issue for this gem) or do openssl headers just need to be installed for you?

janko commented 7 years ago

@jemc I do have OpenSSL installed and have the header file in /usr/local/Cellar/openssl/1.0.2l/include/openssl/conf.h (via Homebrew).

I saw that people had problems installing EventMachine, and that doing gem install eventmachine -- --with-cppflags=-I/usr/local/Cellar/openssl/1.0.2l/include would solve the issue, so I'm searching now the equivalent for C code (EventMachine has C++). I was able to normally install EventMachine, so I'm surprised that a gem with C extensions instead of C++ cannot find OpenSSL.

janko commented 7 years ago

Ok, I found how do it with Puma in https://github.com/puma/puma/issues/718#issuecomment-122632128, so I tried the same thing with rabbitmq:

$ gem install rabbitmq -- --with-opt-include=/usr/local/opt/openssl/include

But I still get the same error 😕. I checked that /usr/local/opt/openssl/include/openssl/conf.h exists.

jemc commented 7 years ago

so I'm surprised that a gem with C extensions instead of C++ cannot find OpenSSL.

Well, the thing is that this gem doesn't actually have a C extension - it just uses the Rakefile hook to build the shared library, then links to that via FFI. That is, it uses a C library, but it doesn't build a C extension onto Ruby itself.

I think it might work to use the env vars recognized by C compilers.

What happens if you run env C_INCLUDE_PATH=/usr/local/opt/openssl/include gem install rabbitmq?

janko commented 7 years ago

@jemc That works! Thank you for the help!