I am trying to build a todo list with Ruby and Ruby on Rails. In my rails application I add the gems I need and then type 'bundle' in my terminal. Everything works until:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/Misha/.rbenv/versions/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.
-----
I go to the link provided and for mac it instructs to do the following commands:
sudo port install libxml2 libxslt
sudo gem install nokogiri
but then i get the command not found. I tried following a similar problem and solution:
sudo vi /etc/paths
Add 2 following lines:
/opt/local/bin
/opt/local/sbin
but still have the same problem.
I suspect sudo port install libxml2 libxslt
is failing because you don't have the MacPorts package manager installed. However, I would install Homebrew instead (which is my personal package manager preference):
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Then continue with the instructions provided in the error message , substituting brew
for sudo port
:
brew install libxml2 libxslt
if that works, try:
sudo gem install nokogiri
Additionally to the answer of @thohl that I totally agree. Nokogiri sometimes is difficult to install. For that reason I keep the following recipe:
cd $( brew --prefix )
git checkout 763d946 Library/Formula/libxml2.rb
brew unlink libxml2
brew install libxml2 libxslt
git checkout master Library/Formula/libxml2.rb
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install nokogiri --verbose -- --with-xslt-dir=$( brew --prefix )/Cellar/libxslt/1.1.28 --with-iconv dir=$( brew --prefix )/Cellar/libiconv/1.14 --with-xml2-include=$( brew --prefix )/Cellar/libxml2/2.8.0/include/libxml2 --with-xml2-lib=$( brew --prefix )/homebrew/Cellar/libxml2/2.8.0/lib --use-system-libraries
These incantations made the trick in my case
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.