Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing gems: cannot load such file -- zlib

Tags:

ruby

gem

I'm trying to install bundler gem on Mac OS Yosmite

~/code/hello 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

I've done the following:

  • Install zlib through homebrew
  • Upgrade Rubygems
  • Reinstall RVM and Ruby 2.2.2
  • Switched to Rbenv and Ruby 2.2.2

This is really doing my head in. Ruby 2.2.1 works fine but 2.2.2 causes this issue whenever I try to install a gem.

Anyone got any ideas?

like image 370
stephenmurdoch Avatar asked May 14 '15 09:05

stephenmurdoch


1 Answers

Try rvm pkg install zlib (from this question)

RVM pkg docs: https://rvm.io/packages


It also looks like RVM has a more up to date way of managing packages called autolibs. Check rvm autolibs show, which I hope will be default(enabled) since you just installed. If it's not, rvm autolibs enable, or you can even tell it to use Homebrew instead of its own manager with rvm autolibs homebrew.

RVM autolibs docs: https://rvm.io/rvm/autolibs

like image 157
Kristján Avatar answered Sep 29 '22 12:09

Kristján