Nokogiri gem fails to install in OS X Mavericks
Asked Answered
B

4

6

Install fails showing:

checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... no
checking for iconv_open() in -liconv... no
checking for libiconv_open() in iconv.h... no
checking for libiconv_open() in -liconv... no
checking for libiconv_open() in -liconv... no
libiconv is missing.

However, looking at nokogiri's mkmf.log, the following errors are shown:

ld: warning: ignoring file /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxslt/1.1.28/lib/libxslt.dylib

ld: warning: ignoring file /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libxml2/2.9.1/lib/libxml2.dylib

ld: warning: ignoring file /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib, **file was built for x86_64 which is not the architecture being linked (i386)**: /usr/local/Cellar/libiconv/1.14/lib/libiconv.dylib

I have xcode and it's command tools installed. My ~/.bash_profile has 64bit compiling forced by: export ARCHFLAGS="-arch x86_64"

I have libxml2, libxslt, and libiconv installed via Homebrew, and each is linked. I've tried installing all of these without the ARCHFLAG in .bash_profile.

I've also brew install apple-gcc42 and linked, as per how tos I've found.

I've tried installing nokogiri by passing paths to libxml2, libxslt, and libiconv in /usr/local/Cellar/, but the install still fails, with same errors as above.

I've wasted at least a day on this - just trying to get one Ruby gem installed. I'd really like to get back to actually developing.

Can anyone please help?

Braid answered 1/5, 2014 at 2:26 Comment(0)
C
21

Setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1 before actually 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 if needed:
    $ 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"

Crusted answered 10/5, 2014 at 20:18 Comment(2)
+1 NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri was sufficient to get this to install for me. This really should be fixed, installs should not be this difficult. I use real nokogiri saws such as dozuki saws and using them to cut dovetails isn't this much trouble.Cutty
+1 for this solution, worked for me too (the official tutorial didn't), however here's the link: nokogiri.org/tutorials/installing_nokogiri.htmlSteamheated
B
0
  • Check if HomeBrew is installed correctly with the appropriate XCode command line tools.

brew doctor

  • You can also check via XCode > Preferences

With valid command line tools installed, I was able to resolve the nokogiri error encountered after the OSX Maverick upgrade.

Also found that some of the 'brew' packages were outdated after the OS X Mountain Lion to Maverick upgrade. (e.g. qt, postgresql)

Bisulfate answered 14/5, 2014 at 5:3 Comment(0)
U
0

Here's what worked for me:

  1. If you haven't already done so, install the XCode developer tools: $ xcode-select --install
  2. Use homebrew to install (or reinstall) libxml2, libxslt and libiconv: $ brew install libxml2 libxslt libiconv
  3. Install nokogiri: gem install nokogiri -- --with-iconv-dir=/usr/local/opt/libiconv

I found the solution I needed in an unmerged pull request to update the Nokogiri tutorials. I recommend that if someone else encounters this issue and has exhausted the solutions here, check that pull request list to see if someone has submitted an update to the instructions on the Nokogiri tutorials page.

Urumchi answered 16/9, 2014 at 23:31 Comment(0)
P
0

From github page First, you should: xcode-select --install and then re-install nokogiri. That worked for me while another suggestion didn't. Hope this helps someone else.

Phenoxide answered 27/9, 2014 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.