How to FIX Zlib missing error on OSX 10.14? - ruby

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

Related

ERROR: Failed to build gem native extension when installing Sablon gem

I am trying to install and use the Sablon ruby gem. I have installed xcode command line developer tools. However, I continue to get the following error:
ERROR: Error installing sablon:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking if the C compiler accepts ... 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.1.0
checking for iconv.h... yes
checking for gzdopen() in -lz... yes
checking for iconv... yes
Any ideas as to what might be going on here?
try
gem install sablon -- --use-system-libraries=true
if it doesn't work may i ask how you installed xcode command line tools?

iconv install failure ruby

I've got huge headache trying to install iconv gem on ruby.
gem install iconv -- --http-proxy http://login:password.#proxy:8080 --with-iconv-dir=\D:\libiconv
Result is:
ERROR: Error installing iconv:
ERROR: Failed to build gem native extension.
current directory: D:/InstantRails/ruby/lib/ruby/gems/2.3.0/gems/iconv-1.0.4/ext/iconv D:/InstantRails/ruby/bin/ruby.exe -r ./siteconf20161020-2784-1sz8avf.rb extconf.rb --http-proxy http://bche:f1r305sty5.#proxy.isd.dp.ua:8080 --with-iconv-dir=D:/libiconv
checking for rb_enc_get() in ruby/encoding.h... yes
checking for rb_sys_fail_str() in ruby.h... yes
checking for iconv() in iconv.h... no
checking for iconv() in -liconv... 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.
I've downloaded all source files that possible. Please help
Iconv has been deprecated since Ruby v 1.9.3, only old gems use it these days and you would better update or replace these.
If you use it yourself, the same functionality can be reached using String.encode or String.scrub (Ruby -v ~> 2.1).
I'm not saying it is impossible to install it but I question the effort you are gonna spend in it isn't better used elsewhere. Had the same problem installing Sqlite in Ruby 2.3.0 and succeeded only after trying multiple times and after a few weeks.

Install gems on Windows with RailInstaller: "You must have zlib installed"

I'm on Windows, with Ruby 2.0 installed using RailsInstaller.
When I tried to install id3lib-ruby using gem install id3lib-ruby, I get the following:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing id3lib-ruby:
ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb
checking for main() in -lstdc++... yes
checking for main() in -lz... no You must have zlib installed.
*** 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.
In mkmf.log, it includes the line:
c:/railsinstaller/devkit/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe: cannot find -lz
collect2: ld returned 1 exit status
I have zlib1.dll in C:\RailsInstaller\Ruby2.0.0\bin, renaming the file to zlib.dll doesn't work. So, it looks like RubyInstaller already included the zlib library, but something's still causing the gem install to fail. Any ideas?
Couldn't work it out. "Fixed" by installing RailsInstaller 2.2.2 (Ruby 1.9.3) and taglib-ruby instead.

sudo gem install rmagick fails

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.

How do I install ruby gem libxml without 'extconf failure: need libxml2'

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

Resources