I found this "Zlib missing" continously when installing gems for Rails on Ruby, please let me know a solution :
Fetching nokogiri 1.10.2
Installing nokogiri 1.10.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.2/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -I /usr/local/Cellar/ruby/2.6.2/lib/ruby/2.6.0 -r ./siteconf20190407-34092-u44l37.rb extconf.rb
checking if the C compiler accepts -I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/libxml2... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.4.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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.
I also re-installed OSX 10.14 SDK header but didn't work.
It turned out that I have to manually download zlib from its site and then install it myself to make it work.
Extract the package then install as instruction :
./Configure
make
make install
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.
As the title says, it doesn't seem to be failing because libxml2 or libxslt is missing. I'm not really sure what to make of the error. (Get it? Because the issue is during make? hehe...)
Anywho, here's the output I'm getting. Any ideas would be appreciated:
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
extconf.rb:10: Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
checking for xmlHasFeature()... yes
checking for xmlFirstElementChild()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetParserStructuredErrors()... yes
checking for xmlRelaxNGSetValidStructuredErrors()... yes
checking for xmlSchemaSetValidStructuredErrors()... yes
checking for xmlSchemaSetParserStructuredErrors()... yes
creating Makefile
make
compiling xml_element_content.c
compiling xml_relax_ng.c
compiling xml_cdata.c
compiling xml_sax_parser_context.c
compiling xml_node_set.c
compiling xml_text.c
compiling xml_sax_parser.c
compiling xml_attribute_decl.c
compiling nokogiri.c
nokogiri.c: In function ‘ruby_strdup’:
nokogiri.c:43:31: warning: conversion to ‘size_t’ from ‘long int’ may change the sign of the result [-Wsign-conversion]
compiling xml_entity_reference.c
compiling xml_node.c
compiling xml_xpath_context.c
xml_xpath_context.c: In function ‘xpath_generic_exception_handler’:
xml_xpath_context.c:184:3: error: format not a string literal and no format arguments [-Werror=format-security]
cc1: some warnings being treated as errors
make: *** [xml_xpath_context.o] Error 1
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.5.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
For context, I upgraded from Ubuntu 12.04 to 12.10 last night. I had previously built the Nokogiri native extension on this box, though I do not know if it was the same version or not.
I also checked that I have all packages specified in the second post on "error installing nokogiri 1.5.0 with rails 3.1.0 and ubuntu"
to no avail.
Took me some time to figure out how to append the cflags. Here is my command for nokogiri 1.4.7:
sudo gem install nokogiri -v '1.4.7' -- --with-cflags=\"-Wformat-nonliteral -Wno-format-security\"
If you're trying to install Nokogiri < 1.5.4, you'll have problems on hardened Debian systems like Ubuntu 12.
Details on the underlying issue are here: https://github.com/sparklemotion/nokogiri/issues/680
You should be able to upgrade to 1.5.4 or later and install without this problem.
Alternatively, you should be able to set the CFLAGS environment variable at gem-install time to include the string:
-Wno-error=format-security
or
-Wformat-nonliteral -Wno-format-security
Good luck!
Have you tried installing the following depencies for nokogiri??
# nokogiri requirements
sudo apt-get install libxslt-dev libxml2-dev
sudo gem install nokogiri
This may be happening due to this bug > https://leap.se/code/issues/7231
Run below before running the command:
sudo apt-get install zlib1g-dev
I am getting this error when I try to install RMagick on my machine so I can play with Scruffy graph creator:
sudo gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/richardjburton/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... yes
checking for HDRI disabled version of ImageMagick... yes
checking for stdint.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.
Any help would be awesome! Thanks.
Looks like you installed ImageMagick using a binary distro or something else which didn't include the headers. From your /Users directory you're probably using OSX. Assuming so, install ImageMagick using either Macports or Homebrew.
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