Error installing gems: cannot load such file — zlib

拈花ヽ惹草 提交于 2019-12-21 12:35:14

问题


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?


回答1:


The following worked for me:

brew install homebrew/dupes/zlib
rvm reinstall 2.2.2 --with-zlib-dir=/usr/local/Cellar/zlib/1.2.8

Hope this helps anyone else who runs into it.




回答2:


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



来源:https://stackoverflow.com/questions/30233255/error-installing-gems-cannot-load-such-file-zlib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!