Reputation: 16781
I know there's a ton of questions about this here on SO, but I really can't manage to install Nokogiri on my OS X 10.8.3 system.
I did the rituals:
brew install libxml2 libiconv libxslt
brew link --force libxml2 libiconv libxslt
but I keep getting these errors after doing a sudo gem install nokogiri
:
Fetching: nokogiri-1.5.5.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
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. 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.
The interesting thing is that the libiconv
error is randomly alternated with a libxml2
error.
I followed the instructions at http://nokogiri.org/tutorials/installing_nokogiri.html but it just doesn't work.
I don't believe what just happened. Really, I don't.
brew uninstall libxml2 libiconv libxslt
It works now, gem
installs it. It complained a little:
No definition for parse_memory
No definition for parse_file
No definition for parse_with
No definition for get_options
No definition for set_options
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rdoc/rdoc.rb:280: warning: conflicting chdir during another chdir block
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rdoc/rdoc.rb:287: warning: conflicting chdir during another chdir block
but at least in Middleman (that's were I'm using it) it works like a charm. Am I crazy?
Upvotes: 0
Views: 1173
Reputation: 16781
What did actually work for me is this.
After you installed brew
, install the following libs:
brew install libxml2 libxslt
Now, in bash (if you're on zsh
, just issue bash
to move to the bash shell) do:
curl -L https://get.rvm.io | bash -s stable --rails --autolibs=enabled
to get RVM (Ruby Version Manager). In your bash|zshrc
, paste the following line:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
to load rvm on startup.
Note that if you didn't install the above libs with brew
, the rvm
installation will fail.
Restart the terminal and then issue:
rvm install 1.9.3 # or the version you like, 1.9.3 worked for nokogiri
And to use this version as the system default just issue:
rvm --default use 1.9.3
gem
Now the gem install nokogiri
command should work fine.
Note that omitting the sudo
is fundamental when dealing with rvm
and gem
stuff. That's one of the things that I missed and made me go crazy.
Upvotes: 1