gem eventmachine fatal error: 'openssl/ssl.h' file not found
Solution 1
$ gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
Building native extensions with: '--with-cppflags=-I/usr/local/opt/openssl/include'
This could take a while...
Successfully installed eventmachine-1.0.8
1 gem installed
You can also set up bundler like this but I think that is superficial
bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
Solution 2
When using bundler and homebrew:
$ bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
$ bundle install
Solution 3
brew link --force openssl
Then:
gem install eventmachine
It also fixes:
- gem install taks
- bundle install
- rake and rails tasks
P.S. Probably you'll need to remove and run brew install openssl
again
The issue happends because Apple had removed openssl from OSX (in El Captain build)
Solution 4
gem pristine eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
pristine removes the old gem and recompiles it.
The cpp flags option allows the compiler to find the openssl headers.
If you prefer to abstract away the cpp flags argument, you can do the following:
PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig"
You can also add the version if you like:
gem pristine eventmachine -v '1.0.4' -- --with-cppflags=-I/usr/local/opt/openssl/include
Solution 5
I was trying to install v 1.0.3 and this worked for me.
gem install eventmachine -v '1.0.3' -- --with-cppflags=-I/usr/local/opt/openssl/include
These discussions were very helpful: https://github.com/eventmachine/eventmachine/issues/602
This assumes the machine already has openssl installed via brew
.
Related videos on Youtube
firedev
Full-stack designer. Specializing in crafting components systems tailored to use cases on hand. Carefully stitching together back and front ends for improved user experience.
Updated on April 23, 2022Comments
-
firedev about 2 years
Just installed El Capitan and can't install gem
eventmachine
1.0.7
.openssl
is at1.0.2a-1
. Tried to use--with-ssl-dir
but it seems ignored.Reported it to their github repo as well.
Any suggestions are really appreciated. Thanks.
$ ls /usr/local/Cellar/openssl/1.0.2a-1/include/openssl/ssl.h /usr/local/Cellar/openssl/1.0.2a-1/include/openssl/ssl.h $ gem install eventmachine -v '1.0.7' -- --with-ssl-dir=/usr/local/Cellar/openssl/1.0.2a-1/include /Users/pain/.rbenv/versions/2.1.2/bin/ruby -r ./siteconf20150612-56154-1hsjz2n.rb extconf.rb --with-ssl-dir=/usr/local/Cellar/openssl/1.0.2a-1/include checking for rb_trap_immediate in ruby.h,rubysig.h... no checking for rb_thread_blocking_region()... yes checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for inotify_init() in sys/inotify.h... no checking for __NR_inotify_init in sys/syscall.h... no checking for writev() in sys/uio.h... yes checking for rb_thread_fd_select()... yes checking for rb_fdset_t in ruby/intern.h... yes checking for rb_wait_for_single_fd()... yes checking for rb_enable_interrupt()... no checking for rb_time_new()... yes checking for sys/event.h... yes checking for sys/queue... yes checking for clock_gettime()... no checking for gethrtime()... no creating Makefile make "DESTDIR=" clean make "DESTDIR=" compiling binder.cpp In file included from binder.cpp:20: ./project.h:116:10: fatal error: 'openssl/ssl.h' file not found #include <openssl/ssl.h> ^ 1 error generated. make: *** [binder.o] Error 1 make failed, exit code 2
-
Ryan Walls over 8 yearsFor me, I had to install openssl first before this worked. e.g.
brew install openssl
-
Ryan Walls over 8 yearsFor me, I had to install openssl first before this worked. e.g.
brew install openssl
. -
Colto over 8 yearsIf you have your gems set to a specific directory in your repo, i.e.
vendor/bundle
then you will want to run thebundle config build.GEMNAME--with-cppflags=-I/usr/local/opt/openssl/include
. I had to run the same thing with the gempuma
so I imagine this is happening for other gems as well. -
justingordon over 8 yearssee answer with: 'bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include' from lloeki. That worked for me. Not this one.
-
dtburgess over 8 yearsThis version worked for me to install eventmachine 1.0.3 on top of ruby 2.1.2
-
jhedstrom over 8 yearsThis was indeed the fix on El Capitan.
-
Abram over 8 yearsFor clarification, what is the order of brew remove/install/link
-
itsnikolay over 8 years@Abram In case of
brew link --force openssl
had no effect. Then dobrew uninstall openssl
,brew install openssl
,brew link --force openssl
-
Ryan Bosinger over 8 yearsThis is the answer on a Mac today (El Capitan, 2015-2016). EDIT: Just forcing the brew openssl. I didn't need to specify a version of EventMachine (I was installing Middleman).
-
Jagdeep Singh almost 8 yearsThis worked for me
gem install eventmachine -v 1.0.8 -- --with-cppflags=-I/usr/local/opt/openssl/include
on OSX El Capitan 10.11.5 -
Sr. Oshiro over 7 yearsfor me after install
brew install openssl
I have to dobrew link openssl --force
-
Ricardo Freitas over 7 yearswhy
pristine
instead ofinstall
? -
Marius Butuc over 7 years
gem install eventmachine -- --with-cppflags=-I$(brew --prefix openssl)/include
-
Dylanthepiguy over 7 years
gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
worked for me. -
Kees Briggs over 7 yearsWorked for me as well. Good call.
-
MaicolBen about 7 yearsYou need a hypen before
I/usr/local/opt/openssl/include
. It's one character so stackoverflow doesn't let me edit it -
morgler about 7 yearsFantastic! This is also the way to go for other gems (e.g. puma) that depend on openssl
-
blockloop almost 7 yearsFixed it @MaicolBen
-
Ernesto almost 7 yearsI think this answer is better than the approved one, because since it uses
bundle install
to perform the actual gem installation, it guarantees you'll install the exact version specified in your bundle. The accepted answer will install the latest version, unless you include the-v x.x.x
in thegem install
command manually. -
Gerry Gleason over 6 yearsUnecessarily complicated, why not just set the var: export PKG_CONFIG_PATH=$( brew --prefix openssl )/lib/pkgconfig # now you can install any packages, add to .bashrc, or what you use
-
Joe over 2 yearsLovely and still works on an M1 MBP and Ruby 3.x.
-
komikat over 2 yearsWorked for me, BigSur 2022.
-
Sheikh Faisal Miskhat about 2 yearsThanks for this solution! I had the problem with eventmachine 1.2.7 installation and this resolved it.