RVM 1.9.1 & nokogiri
Asked Answered
K

3

7

Having trouble installing the nokogiri gem under rvm ruby 1.9.1.

gem install nokogiri

I'm getting ...

/usr/include/libxml2... no
libxml2 is missing.  try 'port install libxml2' or 'yum install libxml2-devel'
*** extconf.rb failed ***

but i checked:

sudo apt-get install libxml2

and i got:

Reading state information... Done
libxml2 is already the newest version.

is this a root thing perhaps? RVM runs everything in userspace.

Kingsly answered 11/3, 2010 at 14:27 Comment(3)
blog.lostincode.net/archives/2010/1/2/… looks goodKingsly
ah - on ubuntu its libxml2-dev not libxml2-develKingsly
On Ubuntu I was suggested to do sudo apt-get install ruby-nokogiri.Schuh
C
3

You might want to confirm that the version of libxml installed by apt is current. Nokogiri likes nice fresh versions of libxml, so I built my libxml install from source.

nokogiri -v will tell you what you're using.

Curacy answered 11/3, 2010 at 17:37 Comment(1)
No problem. I ran into the problem SO many times I figured I should try to head it off at the pass for you.Curacy
U
10

A simpler solution:

sudo apt-get install libxslt-dev libxml2-dev
Upturn answered 31/8, 2011 at 3:6 Comment(2)
Thank you! libxml2-dev is exactly what was missing on ubuntu. Works great to install nokogiri :)Textbook
yum install libxml2-devel libxslt-devel got it working on my centos box, thanks!Indemnity
C
3

You might want to confirm that the version of libxml installed by apt is current. Nokogiri likes nice fresh versions of libxml, so I built my libxml install from source.

nokogiri -v will tell you what you're using.

Curacy answered 11/3, 2010 at 17:37 Comment(1)
No problem. I ran into the problem SO many times I figured I should try to head it off at the pass for you.Curacy
M
2

I ran into a similar problem using homebrew on Mac.

Here's the code that does the trick, a small extension of the Nokogiri installation instructions for homebrew. Basically, you need to include a directive to tell nokogiri to use the homebrew libxml dirs. Make sure you point to the correct version of libxml2 installed by homebrew, which for me was 2.7.8:

brew install libxml2

brew link libxml2 #this may be enough but didn't work for me with rvm

#explicitly tell nokogiri to use you homebrew libxml2 rather than system
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.26
Mercy answered 13/6, 2011 at 22:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.