Friday, October 4, 2013

Installing Ruby: cannot load such file -- [ openssl | zlib ]

If you like me, installed Ruby by compiling from source code manually, and found that this 2 errors when trying to install bundler

  • cannot load such file -- openssl
  • cannot load such file -- zlib
You missed configure make to compile with those 2 libraries. Follow these steps to fix this issue.
  1. Remove the installed Ruby with make clean
  2. Install libssl-dev with your OS's package manager of choice. E.g. apt-get install libssl-dev
  3. Install zlib1g-dev with your OS's package manager of choice. E.g. apt-get install zlib1g-dev
  4. Config make file to include openssl by go to ext/openssl and run ruby extconf.rb
  5. Config make file to include zlib by go to ext/zlib and run ruby extconf.rb
  6. Go back to ruby source code directory run make && make install
  7. You should be able to successfully run gem install bundler
You can also do the same thing for readline. Install libreadline-dev and run extconf.rb in ext/readline

Tested with ruby 2.0.0p247
Credit:

4 comments:

Anonymous said...

Thank you. This worked liked a breeze!

Unknown said...

Thank you.

Anonymous said...

worked like a charm .. thanks much!

Mohsin Khan said...

hi,

It doesnt work for me I am getting same error after follow your steps.

mohsin@vw-ubuntu-android-01:/tmp/ruby/ruby-2.1.2$ gem install bundler
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

Collectd PostgreSQL Plugin

I couldn't find this link when searching with google https://www.collectd.org/documentation/manpages/collectd.conf.html#plugin-postgresq...