在OSX Mavericks上安装Ruby on Rails时libxml2的问题

时间:2015-02-27 13:42:34

标签: ruby-on-rails osx-mavericks libxml2

我在终端上安装Ruby on Rails时遇到问题。

是否有其他人在终端中遇到以下错误:

checking for main() in -llzma... yes
checking for xmlParseDoc() in libxml/parser.h... no
checking for xmlParseDoc() in -lxml2... no
checking for xmlParseDoc() in -llibxml2... no
-----
libxml2 is missing.  Please locate mkmf.log to investigate how it is failing.
-----
*** 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.

我正在使用标准bash:

$ gem install rails

我该如何解决这个问题?我已经在堆栈交换上尝试了一些东西但到目前为止没有任何工作......

在终端中使用$ brew list会产生:

Michaels-iMac:~ iMacHome$ brew list
autoconf    libksba     libxslt     pkg-config
automake    libtool     libyaml     readline
libgpg-error    libxml2     openssl
Michaels-iMac:~ iMacHome$

好像在那里......

2 个答案:

答案 0 :(得分:4)

假设您已安装Xcode,请尝试此

gem install rails -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.‌platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 --use-system-libraries

答案 1 :(得分:2)

问题可能是您的RVM。

尝试以下命令:

 rvm cleanup all
 rvm pkg uninstall libxml2
 rvm reinstall all --force

或升级/重新安装到最新的RVM安装。

- 要为Ruby版本全局正确安装rails gem:

rvm use <rubyversion>
gem install rails

在ruby 2.1.5上使用rails的例子:

rvm use 2.1.5
gem install rails