Why aren't “gem” and “bundle” using the same libxml2?

坚强是说给别人听的谎言 提交于 2020-06-23 06:56:11

问题


I seem to be in a recursive loop of frustration. I'm trying to "bundle install" a project, but it results in:

An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.6.2'` succeeds before bundling.

So I try that:

$ gem install nokogiri -v '1.6.6.2'
Building native extensions.  This could take a while...
Successfully installed nokogiri-1.6.6.2
Parsing documentation for nokogiri-1.6.6.2
Done installing documentation for nokogiri after 2 seconds
1 gem installed

All good! Except that when I run "bundle install", I am again told I need to get "gem install nokogiri -v '1.6.6.2'" to install first. AHHHHH.

The mkmf.log file suggests this is an issue with libxml2 (surprise surprise).

conftest.c:3:10: fatal error: 'libxml/xmlversion.h' file not found
#include <libxml/xmlversion.h>
         ^
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <libxml/xmlversion.h>
4: 
5: #if LIBXML_VERSION < 20621
6: #error libxml2 is way too old
7: #endif
/* end */

So, searching for libxml2 (with "sudo find / -name libxml2") reveals these directories, all of which appear to be at least 2.9.0 or higher:

  • /usr/include/libxml2
  • /usr/local/Cellar/libxml2
  • /usr/local/opt/libxml2

So, is the issue that libxml2 can't be found? And if so, how do I get bundle install to realize that nokogiri is already installed, or at least be able to install it the same way "gem install" does? While I'd like to find a solution for this, I'm really interested in learning what is going on "under the covers" so I can troubleshoot in the future.


回答1:


On my Mac OS X, I ran these commands, and the problem is fixed.

brew unlink gcc-4.2      # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri


来源:https://stackoverflow.com/questions/32466606/why-arent-gem-and-bundle-using-the-same-libxml2

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