Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was finally able to solve this problem. None of the above solutions completely fixed it for me.</p> <p>I was getting this error when trying to <code>gem install nokogiri</code> on OSX Lion 10.7.2. First of all, this error masks the real problem by saying libiconv is missing, because you will get the same error even if nokogiri can't find libxslt or libxml2, which in my case, it couldn't.</p> <p>So I followed the instructions on <a href="http://nokogiri.org/tutorials/installing_nokogiri.html">http://nokogiri.org/tutorials/installing_nokogiri.html</a> under the Homebrew section (slightly modified to account for a more current version of libxml2):</p> <pre><code>brew install libxml2 brew link libxml2 # install libxslt from source wget ftp://xmlsoft.org/libxml2/libxslt-1.1.26.tar.gz tar -zxvf libxslt-1.1.26.tar.gz cd libxslt-1.1.26 ./configure --prefix=/usr/local/Cellar/libxslt/1.1.26 --with-libxml-prefix=/usr/local/Cellar/libxml2/2.7.8 make sudo make install </code></pre> <p>At this point I followed the directions on the nokogiri site and tried</p> <pre><code>gem install nokogiri -- --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26 </code></pre> <p>However, this still failed because when building libxslt from source, it installs the <code>/include</code> folder in a funky place. So you need to specify the <code>lib</code> and <code>include</code> folders separately like so:</p> <pre><code>gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt </code></pre> <p>This still didn't work (same libiconv error), so I tried to specify all three required libraries (libxslt, libxml2 and libiconv):</p> <pre><code>gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8 </code></pre> <p>Now I got a different error! It was still an error but at least it was different. The make process failed with:</p> <pre><code>in /opt/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64 </code></pre> <p>Uhh, what? After a lot of googling, I came across this miracle post: <a href="http://www.refresherate.com/2010/01/08/fixing-ld-warning-in-usrlocalliblibz-dylib-file-is-not-of-required-architecture/">http://www.refresherate.com/2010/01/08/fixing-ld-warning-in-usrlocalliblibz-dylib-file-is-not-of-required-architecture/</a></p> <p>Apparently OSX Lion ships with some bad versions of the libz library (<code>libz.dylib, libz.1.dylib, libz.1.2.4.dylib</code>) and and they need to be replaced with the latest versions from the Xcode SDK. The article explains it better than I can so read the above link for specific instructions.</p> <p>Once these were replaced, I ran </p> <pre><code>gem install nokogiri -- --with-xslt-lib=/usr/local/Cellar/libxslt/1.1.26/lib --with-xslt-include=/usr/local/Cellar/libxslt/1.1.26/include/libxslt --with-iconv-dir=/usr/local/Cellar/libiconv/1.14 --with-xml2-dir=/usr/local/Cellar/libxml2/2.7.8 </code></pre> <p>again and all was well. I hope this helps someone else.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload