问题
I'm having a problem installing Ruby on Rails in my terminal.
Has anyone else encountered the following error in the terminal:
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.
I'm using the standard bash:
$ gem install rails
How would I go about fixing this? I've tried a few things here on stack exchange but nothing so far has worked...
Using $ brew list
in the terminal yields:
Michaels-iMac:~ iMacHome$ brew list
autoconf libksba libxslt pkg-config
automake libtool libyaml readline
libgpg-error libxml2 openssl
Michaels-iMac:~ iMacHome$
It seems to be there...
回答1:
assuming you have Xcode installed try this
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
回答2:
The problem could be your RVM.
Try either this command:
rvm cleanup all
rvm pkg uninstall libxml2
rvm reinstall all --force
or upgrade/reinstall to the latest RVM installation.
-- To properly install the rails gem globally for a Ruby version:
rvm use <rubyversion>
gem install rails
example to use rails on ruby 2.1.5:
rvm use 2.1.5
gem install rails
来源:https://stackoverflow.com/questions/28766516/problems-with-libxml2-when-installing-ruby-on-rails-on-osx-mavericks