5

I am trying to install Ruby on Rails via RVM on Yosemite. Everything seems to have worked, though, when I attempt to run 'bundle install' I am presented with an error relating to Nokogiri:

pauls-air:~ paulmcguane$ gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
Building native extensions with: '--with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib'
This could take a while...
Building nokogiri using packaged libraries.
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

The error message is:

/Users/paulmcguane/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
-----
libiconv 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.

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/paulmcguane/.rvm/rubies/ruby-2.1.2/bin/ruby
        --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

extconf failed, exit code 1
IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Boss Nass
  • 3,384
  • 9
  • 48
  • 90
  • You should probably let nokogiri use its bundled version of lib xml rather than forcing the use of one you've installed (although it looks like it might be doing that anyway) In addition there should be mention in the error message of a log file with the precise compile error. – Frederick Cheung Jun 08 '14 at 11:37
  • 1
    Haven't installed on Yosemite. But I would start again with this with a fresh gemset and make sure Nokogiri is listed BEFORE rails (or any other gem). This can make sure Nokogiri uses its embedded libxml2 (which stops you having problems with first-child). see also https://github.com/sparklemotion/nokogiri/issues/742#issuecomment-9082139 and https://github.com/sparklemotion/nokogiri/issues/829 – Tim Diggins Jun 08 '14 at 14:01
  • You can try this answer: http://stackoverflow.com/questions/24091869/installing-nokogiri-on-osx-10-10-yosemite?answertab=active#tab-top – activars Jun 10 '14 at 22:04

2 Answers2

3

I just did a full installation of Rails and Ruby and everything you need. I followed these steps.

https://gorails.com/setup/osx/10.10-yosemite

and use the following to install nokogiri

xcode-select --install
gem install nokogiri
bundle config build.nokogiri --use-system-libraries
bundle install
a14m
  • 7,808
  • 8
  • 50
  • 67
TheRealRonDez
  • 2,807
  • 2
  • 30
  • 40
  • 2
    Beautiful. Only needed the first line `xcode-select --install`, then I was able to `bundle install` without issue. – colllin Nov 02 '14 at 03:39
0

I got this to work using macports instead of homebrew. My configuration:

  1. Install the latest Xcode Beta (Beta 3 at time of writing).
  2. xcode-select --switch /Applications/Xcode-Beta3
  3. macports built/installed from source, per installation instructions here
  4. sudo port install libxml2 libxslt
  5. gem install nokogiri -- --with-iconv-include=/opt/local/include/

A little convoluted, but everything worked fine after that.

patr1ck
  • 964
  • 7
  • 13