由于未正确检测到 libxml2,无法安装 Rails

Unable to install Rails due to libxml2 not detected properly

我正在尝试在我的 Mac (Yosemite) 上安装 Rails。我已经解决了几个 SO 问题,用 Homebrew 和 RVM 重新安装了 libxml2,并更新了 Ruby,等等,但到目前为止没有任何效果。我的libxml2版本是2.9.2.

ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

接下来我应该尝试什么?

您在构建 nokogiri 时遇到问题。

请尝试以下步骤。这应该适用于 Yosemite:

brew install libxml2

bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"

bundle install