Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
471 views
in Technique[技术] by (71.8m points)

ruby on rails - OS X Lion, Attempting Nokogiri install - libxml2 is missing

sudo gem install nokogiri
Building native extensions.  This could take a while...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

        /Users/sajeev86/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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 can't get Nokogiri to install. This has been taxing me for a while now. I've installed the dependencies via MacPorts and Homebrew as well.

I've got a feeling the right directories are not pointed to each other? But haven't a clue how to fix.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In Mavericks, installing the libraries with Homebrew and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before installing the gem did the trick for me.

Summarising:

  • If previously installed, uninstall the gem:
    $ gem uninstall nokogiri

  • Use Homebrew to install libxml2, libxslt and libiconv:
    $ brew install libxml2 libxslt libiconv

  • Install the gem specifying the paths to the libraries to be linked against:
    $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...