0

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?

Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
Mithrand1r
  • 2,313
  • 9
  • 37
  • 76
  • possible duplicate of [cannot load such file -- zlib even after using rvm pkg install zlib](http://stackoverflow.com/questions/9727908/cannot-load-such-file-zlib-even-after-using-rvm-pkg-install-zlib), specifically this comment: http://stackoverflow.com/questions/9727908/cannot-load-such-file-zlib-even-after-using-rvm-pkg-install-zlib#comment-15076165 – Patrick Oscity Dec 09 '14 at 12:35
  • @PatrickOscity as long as it actually could be duplicate its another case because I am unable to use Internet Connection at my CentOS so each try of using rvm will fale. however I did manage to make it otherway by following steps in http://visibletrap.blogspot.com/2013/10/installing-ruby-cannot-load-such-file.html – Mithrand1r Dec 09 '14 at 13:26
  • Nice. Please add that as an answer and accept your own answer as soon as it is possible. This will maybe help future visitors. Thanks! – Patrick Oscity Dec 09 '14 at 13:37

1 Answers1

2

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
Scott Weldon
  • 9,673
  • 6
  • 48
  • 67
Mithrand1r
  • 2,313
  • 9
  • 37
  • 76