Mithrand1r Mithrand1r - 6 months ago 16
Ruby Question

Gem install error related to missing library

I installed Ruby v2.1.4 from source. I installed all necessary libaries using:

yum install gcc g++ make automake autoconf curl-devel openssl-devel zlib-devel httpd-devel apr-devel apr-util-devel sqlite-devel


All succeeded.

Now when I want to install a gem with:

gem install bundler-1.7.4.gem


I get:

ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass


I am sure that zlib is installed:

locate zlib


results in a long list of

/lib/modules/2.6.32-431.el6.x86_64/kernel/crypto/zlib.ko
/lib/modules/2.6.32-431.el6.x86_64/kernel/lib/zlib_deflate
/lib/modules/2.6.32-431.el6.x86_64/kernel/lib/zlib_deflate/zlib_deflate.ko
/lib64/rsyslog/lmzlibw.so
/usr/include/zlib.h
/usr/lib64/pkgconfig/zlib.pc
/usr/lib64/python2.6/encodings/zlib_codec.py
/usr/lib64/python2.6/encodings/zlib_codec.pyc
/usr/lib64/python2.6/encodings/zlib_codec.pyo
/usr/lib64/python2.6/lib-dynload/zlibmodule.so
/usr/local/share/doc/ruby/capi/html/db/d74/zlib_8c.html
/usr/local/share/doc/ruby/capi/html/db/d74/zlib_8c_source.html
/usr/local/share/ri/2.1.0/system/Zlib/zlib_version-c.ri
/usr/share/doc/zlib-1.2.3
/usr/share/doc/zlib-devel-1.2.3
/usr/share/doc/zlib-1.2.3/ChangeLog
/usr/share/doc/zlib-1.2.3/FAQ
/usr/share/doc/zlib-1.2.3/README
/usr/share/doc/zlib-devel-1.2.3/README
/usr/share/doc/zlib-devel-1.2.3/algorithm.txt
/usr/share/doc/zlib-devel-1.2.3/example.c
/usr/share/doc/zlib-devel-1.2.3/minigzip.c
/usr/share/man/man3/zlib.3.gz
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/zlib
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/crypto/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/jffs2/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/ubifs/fs/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/zlib/deflate.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/config/zlib/inflate.h
/usr/src/kernels/2.6.32-431.el6.x86_64/include/linux/zlib.h
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_deflate
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_inflate
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_deflate/Makefile
/usr/src/kernels/2.6.32-431.el6.x86_64/lib/zlib_inflate/Makefile


Did I miss something?

Answer

I have found the solution at this blog. I am unable to use rvm because server have no internet connection even through proxy.

While installing ruby from sources doing the following solved the issue:

  • Remove the installed Ruby with make clean
  • Install libssl-dev with your OS's package manager of choice. E.g. apt-get install libssl-dev
  • Install zlib1g-dev with your OS's package manager of choice. E.g. apt-get install zlib1g-dev
  • Config make file to include openssl by go to ext/openssl and run ruby extconf.rb
  • Config make file to include zlib by go to ext/zlib and run ruby extconf.rb
  • Go back to ruby source code directory run make && make install
  • You should be able to successfully run gem install bundler