6

I'm trying to install Rails 4.2.0 on my computer, but I am having issues installing Nokogiri. I followed the steps in the first answer for "bundle install stopped at Nokogiri", but when I run brew install nokogiri, I get the following:

Activating libxslt 1.1.28 (from /Users/dseibert/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2/ports/x86_64-apple-darwin14.0.0/libxslt/1.1.28)...
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.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/dseibert/.rvm/rubies/ruby-2.2.0/bin/$(RUBY_BASE_NAME)
    --help
    --clean
    --use-system-libraries
    --enable-static
    --disable-static
    --with-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --enable-cross-build
    --disable-cross-build
    --with-xml2lib
    --without-xml2lib
    --with-libxml2lib
    --without-libxml2lib

extconf failed, exit code 1

Gem files will remain installed in /Users/dseibert/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/dseibert/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/nokogiri-1.6.6.2/gem_make.out

I cant find the mkmf file to locate the details of my libxml2 file, and I don't see either the libxml2 file or the Nokogiri folder within my Ruby source folder.

And when I run brew install libxml2, I get Warning: libxml2-2.9.2 already installed.


Following the comment, I got the response: Successfully installed nokogiri-1.6.6.2. But when I ran sudo gem install rails, I got back the above error again.

Community
  • 1
  • 1
Dave
  • 61
  • 3
  • http://stackoverflow.com/questions/19643153/error-to-install-nokogiri-on-osx-10-9-maverick – Justin D. Feb 01 '15 at 01:37
  • Welcome to Stack Overflow. It's not necessary to say "Update..." or "Edit..." or things like that. We can see changes to your question once we have sufficient points. Nor is it necessary to thank us, and it's somewhat discouraged. Stack Overflow has a goal of being a Wikipedia-like resource for programming questions. As such, questions are references. Have you ever seen anyone say thank you or request help in an encyclopedia? Just ask good questions, don't worry about having a conversation, and you'll do well. – the Tin Man Feb 02 '15 at 23:13
  • You solved this? Share here why i have this error too. :/ – Adriano Resende Feb 04 '15 at 21:00
  • Don't use `sudo gem install rails`. `sudo` escalates your priviliges to that of root, which has an entirely different idea of where Ruby exists on your machine. When using RVM or rbenv, NEVER use `sudo` to install a gem. Instead simply use `gem install some_gem` and you should be fine. – the Tin Man Jul 01 '15 at 00:49
  • Please see this: http://stackoverflow.com/questions/19643153/error-to-install-nokogiri-on-osx-10-9-maverick The most voted answer has worked for me. It also has updates for Yosemite and El Capitan. – Fabio Cionini Oct 09 '15 at 13:41

2 Answers2

4

Try this

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

This works on OSX 10.11 El Capitan

Cœur
  • 37,241
  • 25
  • 195
  • 267
Zigii Wong
  • 7,766
  • 8
  • 51
  • 79
1

Try this:

bundle config build.nokogiri --use-system-libraries
bundle install

This works on rails 4.2.0, OS X 10.11.2 El Capitan and Xcode 7.2.1 installed You will get while running bundler:

Installing nokogiri 1.6.7.2 with native extensions
Mohamed El-Nakeep
  • 6,580
  • 4
  • 35
  • 39