I always worked my way around Nokogiri installation issues by following the documentation in the \"Installing Nokogiri\" tutorial.
But this time, even after installi
For anyone else experiencing this issue, I solved it by running this command within the project directory
gem install nokogiri -- --use-system-libraries
Update: I ran into this again and tried just updating the gem which worked for me...
gem update nokogiri
I was able to install Nokogiri by running the following packages:
$ dnf group install "C Development Tools and Libraries"
$ dnf install ruby-devel libxml2-devel patch
On Mac OS X Yosemite my mistake was that I tried to use sudo gem install
when it's a rule of thumb to not use superuser privileges when installing gems.
In my case it tried to modify the system installation of Ruby, and that's not a good idea. I installed rbenv, installed Ruby 2.2.2 thru it and set it as global
, which is a term from rbenv's documentation. After that Nokogiri could install itself with a simple
gem install nokogiri
No hacks or workarounds were necessary, just a properly set environment; Nokogiri does the rest perfectly.
It will be:
sudo yum install -y libxml2 libxml2-devel
on RHEL servers.
In Mac OS X (Mavericks), installing the libraries with brew
and setting NOKOGIRI_USE_SYSTEM_LIBRARIES=1
before 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
:
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"
For Windows x64:
gem inst nokogiri --pre --platform ruby
For more information check this thread: https://github.com/sparklemotion/nokogiri/issues/864