RVM 1.9.1 & nokogiri

依然范特西╮ 提交于 2019-12-08 17:34:07

问题


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.


回答1:


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.




回答2:


A simpler solution:

sudo apt-get install libxslt-dev libxml2-dev



回答3:


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


来源:https://stackoverflow.com/questions/2425676/rvm-1-9-1-nokogiri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!