Just installed El Capitan and can't install gem eventmachine 1.0.7. openssl is at 1.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
$ 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
When using bundler and homebrew:
$ bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
$ bundle install
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)
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
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.
This solved the problem for me:
PKG_CONFIG_PATH="$(brew --prefix openssl)/lib/pkgconfig" gem install eventmachine -v "1.0.8"
Source: https://github.com/sj26/mailcatcher/issues/254
If you're installing EventMachine as a dependency of another gem, be sure to specify the correct version when you manually install the gem:
gem install eventmachine -v 1.0.5 -- --with-cppflags=-I$(brew --prefix openssl)/include
Then you can install the gem that you were originally trying to install:
gem install mailcatcher
One alternative is to add a bundler config entry for your whole user profile, like this:
cd ~
bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include
it'll create a .bundle/config file in your home directory, which is then used in all your projects when you run bundle install.
This looks like a more recent issue: https://github.com/eventmachine/eventmachine/issues/936
I solved this problem on macOS 12.3.1 with the following:
M1 Max:
gem install eventmachine -- --with-openssl-dir=/opt/homebrew/Cellar/openssl#1.1/1.1.1n/
Intel:
gem install eventmachine -- --with-openssl-dir=/usr/local/Cellar/openssl#1.1/1.1.1n/
This worked for me -
gem install eventmachine -v '1.0.7' -- --debug --backtrace --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib
Building native extensions with: '--debug --backtrace --with-cppflags=-I/usr/local/opt/openssl/include --with-ldflags=-L/usr/local/opt/openssl/lib'
This could take a while...
Successfully installed eventmachine-1.0.7
Parsing documentation for eventmachine-1.0.7
Installing ri documentation for eventmachine-1.0.7
Done installing documentation for eventmachine after 9 seconds
1 gem installed
NOTE:- Before I was able to successfully install this gem, I had to do a few things. These might apply to you, so listing them here -
1.) got off the corporate-VPN
OR you might have to turn ON proxy settings
2.) PKG_CONFIG_PATH was set to -
echo $PKG_CONFIG_PATH
/usr/local/opt/openssl/lib/pkgconfig
3.) had to add the following to $PATH in bash_profile (in my case ~/.zshrc)
export PATH="/usr/local/opt/openssl/bin:$PATH"
4.) Also note, that contrary to some answers I got in this SO post, and also this thread on github-eventmachine, I was not able to install eventmachine
gem install eventmachine -v '1.0.7' -- --debug --backtrace --with-cppflags=-I/usr/local/include --with-ldflags=-L/usr/local/lib
Fetching: eventmachine-1.0.7.gem (100%)
Building native extensions with: '--debug --backtrace --with-cppflags=-I/usr/local/include --with-ldflags=-L/usr/local/lib'
This could take a while...
ERROR: Error installing eventmachine:
ERROR: Failed to build gem native extension.
It seems /usr/local/opt/openssl/include is the right location and not /usr/local/include when specifying the openssl location.
This installed it for me:
gem install eventmachine -- --with-openssl-dir=/usr/local/opt/openssl#1.1
I got it from the eventmachine Github repo. Evidently OpenSSL tools were moved / removed from MacOS at some point.
In my case, I wanted to install something else (mailcatcher) with a dependency on eventmachine. I did this by replacing eventmachine with mailcatcher in the above command.
I met the same eventmachine issue and the answers above didn't work for me, finally reinstall ruby with given openssl version works:
rvm reinstall 3.1.2 --with-openssl-dir=/usr/local/opt/openssl#3
For Jekyll and Fish:
gem install jekyll -- --with-cppflags=-I(brew --prefix openssl)/include
As of 2022, the way to install eventmachine, assuming brew install openssl has already installed successfully, is: gem install eventmachine -- --with-cppflags=-I/opt/homebrew/opt/openssl/include
Notice that the include directory has moved.
With openssl#3 with Homebrew it worked by running this command:
gem install eventmachine -- --with-openssl-dir=/usr/local/opt/openssl#3/bin/openssl
NOTE the /bin/openssl at the end which made the difference for me.
Here is the cropped error when I tried the command 'gem install mechanize'
Building native extensions. This could take a while...
C:/Ruby/bin/ruby.exe extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokog
iri.html for help with installing dependencies.
-----
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.
then I tried to install the libxml using 'gem install libxml' and it returns following error
ERROR: Possible alternatives: eimxml, eim_xml, irxml, libacl, libowl
It will be better if there is any EXE or precompiled installer that can install the mechanize with all the dependencies.
I am using Windows7(64 bit) and, ruby 2.0.0p247 (2013-06-27) [x64-mingw32]
I'm having trouble installing Nokogiri. When I run bundle install or gem install nokogiri the installation fails.
The error I'm getting is:
(Note: This failure is from using the installation command on nokogiri.org)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/Users/roneesh/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28/ --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
Extracting libxml2-2.8.0.tar.gz into tmp//ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... ERROR, review 'tmp//ports/libxml2/2.8.0/configure.log' to see what happened.
*** 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.
The command I'm trying to use is:
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28/ --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib
I have installed xml2, xslt and libiconv all with brew, and put in their proper versions above. Still no resolution. The only thing I haven't done is libiconv from source (my wget command isn't working for some reason).
You need to specify nokogiri to use the system libraries instead, so it doesn't try to build them itself.
NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install
Answer found here: Error installing nokogiri 1.6.0 on mac (libxml2).
Setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 also did the trick for me, but I had to install the native libraries the gem depends on first (I did it with Homebrew) and then tell the gem to use them.
Summarising:
If previously installed, uninstall the gem:
$ gem uninstall nokogiri
Use Homebrew to install libxml2, libxslt and libiconv:
$ brew install libxml2 libxslt libiconv
Install the gem specifying the paths to the libraries to be linked against:
$ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
I'm trying to setup environtment for ruby project.
But when I run 'bundle', I have error during installing 'fii' gem:
Installing ffi (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/bmalets/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
checking for ffi.h... *** 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.
/Users/bmalets/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
Gem files will remain installed in /Users/bmalets/.rvm/gems/ruby-1.9.3-p448#api2/gems/ffi-1.8.1 for inspection.
Results logged to /Users/bmalets/.rvm/gems/ruby-1.9.3-p448#api2/gems/ffi-1.8.1/ext/ffi_c/gem_make.out
An error occurred while installing ffi (1.8.1), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.8.1'` succeeds before bundling.
My environment:
OS_X 10.8.4
ruby 1.9.3p448
Xcode 4.6.3
libffi-3.0.13
Please, help me to fix it.
Make sure that you have installed Apple Xcode and Command Line Tools (look at this screenshot):
https://developer.apple.com/technologies/tools/
After that, don't forget to install libffi.
1) if you are using homebrew
brew install libffi
2) if you are using macport
sudo port install libffi
I'm currently trying to install a ruby gem which fails because extconf says it needs libxml, so when I follow these instructions to install libxml (which includes these instructions for the ruby dev kit installation) I get the following output:
$ gem install libxml-ruby --platform x86-mswin32-60
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing libxml-ruby:
ERROR: Failed to build gem native extension.
c:/Ruby/bin/ruby.exe extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... yes
checking for inflate() in -lz... no
checking for inflate() in -lzlib... no
checking for inflate() in -lzlib1... yes
checking for iconv_open() in -liconv... no
checking for libiconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
checking for xmlParseDoc() in -lxml2... 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.
Provided configuration options:
--with-opt-dir
--8<--
--with-xml2lib
--without-xml2lib
extconf failure: need libxml2.
Install the library or try one of the following options to extconf.rb:
--with-xml2-config=/path/to/xml2-config
--with-xml2-dir=/path/to/libxml2
--with-xml2-lib=/path/to/libxml2/lib
--with-xml2-include=/path/to/libxml2/include
Gem files will remain installed in c:/Ruby/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.2.2 for inspection.
Results logged to c:/Ruby/lib/ruby/gems/1.9.1/gems/libxml-ruby-2.2.2/ext/libxml/gem_make.out
I'm on a Windows 7 x64 install using my minGW32-shell/git to install. The install fails with the same message from the windows ruby-enhanced command promt.
fwiw:
$ ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
$ git --version
git version 1.7.6.msysgit.0
$ gem -v
1.8.10
You should try the nokogiri gem instead of using libxml-ruby. It includes the precompiled libxml2 dlls as part of the installation, so you don't have to worry about building it yourself.
Nokogiri's API is different from libxml-ruby's, but I'm sure you'll find the same functionality.
If libxml-ruby is a dependency for another gem or app, you probably can't use nokogiri. What are you trying to do?
I had this as a comment, but was asked to post it as an answer for visibility:
The answer to this question solved my problem: libxml-ruby failed to load at x86_64
Try to run
yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
Than it should work
try first with;
yum install -y libxml2 libxml2-devel
If libxslt needed, then
yum install -y libxslt libxslt-devel