Rbenv:无法安装 2.2.0 或 2.2.1。无法在 2.2.2 (OSX 10.10.4) 上“gem 安装捆绑器”

Rbenv: unable to install 2.2.0 or 2.2.1. unable to `gem install bundler` on 2.2.2 (OSX 10.10.4)

在我尝试为这个其他问题找到解决方案时,我感到很沮丧,并且刚刚删除了我的 Ruby 安装 rm -rf ~/.rbenv/versions/2.2.2。使用 rbenv install 2.2.2 重新安装后,我发现突然无法安装 bundler gem。 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

我读过的所有内容似乎都表明缺少 zlib 包通常是 Linux 系统的问题。但是,我使用的是 OSX 10.10.4,并且我读到 zlib 应该与我拥有的命令行工具一起提供。

经过大量谷歌搜索但没有任何进展后,我决定重新开始使用 rbenv。我卸载了 rbenv 并重新安装了它,但我仍然无法使用 ruby 2.2.2 的 rbenv 安装来安装捆绑器。而且,我发现我根本无法安装 2.2.0 或 2.2.1 版本:

MacBook-Pro:~ me$ rbenv install 2.2.0
Downloading ruby-2.2.0.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/7671e394abfb5d262fbcd3b27a71bf78737c7e9347fa21c39e58b0bb9c4840fc
Installing ruby-2.2.0...

BUILD FAILED (OS X 10.10.4 using ruby-build 20150519)

Inspect or clean up the working tree at /var/folders/rm/38vbv5g952s54r1txrmrdlf40000gn/T/ruby-build.20150705212307.49958
Results logged to /var/folders/rm/38vbv5g952s54r1txrmrdlf40000gn/T/ruby-build.20150705212307.49958.log

Last 10 log lines:
    from /private/var/folders/rm/38vbv5g952s54r1txrmrdlf40000gn/T/ruby-build.20150705212307.49958/ruby-2.2.0/lib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /private/var/folders/rm/38vbv5g952s54r1txrmrdlf40000gn/T/ruby-build.20150705212307.49958/ruby-2.2.0/lib/rubygems.rb:556:in `install'
    from ./tool/rbinstall.rb:717:in `block (2 levels) in <main>'
    from ./tool/rbinstall.rb:716:in `each'
    from ./tool/rbinstall.rb:716:in `block in <main>'
    from ./tool/rbinstall.rb:749:in `call'
    from ./tool/rbinstall.rb:749:in `block in <main>'
    from ./tool/rbinstall.rb:746:in `each'
    from ./tool/rbinstall.rb:746:in `<main>'
make: *** [do-install-all] Error 1 

我完全没有想法,如果有人认为他们可能知道发生了什么,我将不胜感激。此时我的开发环境几乎完全被控制了。

编辑

来自 运行 的输出 brew doctor:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libatk-1.0.0.2209.1.dylib
    /usr/local/lib/libgdk-x11-2.0.0.1200.0.dylib
    /usr/local/lib/libgdk_pixbuf-2.0.0.1200.0.dylib
    /usr/local/lib/libgdk_pixbuf_xlib-2.0.0.1200.0.dylib
    /usr/local/lib/libgio-2.0.0.0.0.dylib
    /usr/local/lib/libGLEW.1.5.4.dylib
    /usr/local/lib/libglib-2.0.0.1600.0.dylib
    /usr/local/lib/libgmodule-2.0.0.1600.0.dylib
    /usr/local/lib/libgobject-2.0.0.1600.0.dylib
    /usr/local/lib/libgthread-2.0.0.1600.0.dylib
    /usr/local/lib/libgtk-x11-2.0.0.1200.0.dylib
    /usr/local/lib/libintl.8.0.2.dylib
    /usr/local/lib/libjpeg.62.dylib
    /usr/local/lib/libpango-1.0.0.2100.0.dylib
    /usr/local/lib/libpangocairo-1.0.0.2100.0.dylib
    /usr/local/lib/libpangoft2-1.0.0.2100.0.dylib
    /usr/local/lib/libpangox-1.0.0.2100.0.dylib
    /usr/local/lib/libpangoxft-1.0.0.2100.0.dylib
    /usr/local/lib/libportaudio.2.0.0.dylib
    /usr/local/lib/libSDL-1.2.0.dylib
    /usr/local/lib/libz.1.2.5.dylib

Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
    /usr/local/lib/libatk-1.0.la
    /usr/local/lib/libgdk-x11-2.0.la
    /usr/local/lib/libgdk_pixbuf-2.0.la
    /usr/local/lib/libgdk_pixbuf_xlib-2.0.la
    /usr/local/lib/libgio-2.0.la
    /usr/local/lib/libglib-2.0.la
    /usr/local/lib/libgmodule-2.0.la
    /usr/local/lib/libgobject-2.0.la
    /usr/local/lib/libgthread-2.0.la
    /usr/local/lib/libgtk-x11-2.0.la
    /usr/local/lib/libintl.la
    /usr/local/lib/libjpeg.la
    /usr/local/lib/libpango-1.0.la
    /usr/local/lib/libpangocairo-1.0.la
    /usr/local/lib/libpangoft2-1.0.la
    /usr/local/lib/libpangox-1.0.la
    /usr/local/lib/libpangoxft-1.0.la
    /usr/local/lib/libportaudio.la

Warning: Unbrewed static libraries were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected static libraries:
    /usr/local/lib/libintl.a
    /usr/local/lib/libjpeg.a
    /usr/local/lib/libportaudio.a
    /usr/local/lib/libz.a

结果是 a) 我的 Xcode 安装出了点问题(不确定 what/how 是否会发生)或 b) 需要手动更新 Xcode升级后 OSX.

即使我已经升级了命令行工具,我还是决定检查我在 App Store 中的 Xcode 安装,并注意到可以 install/update。所以我这样做了,然后一切正常。