我似乎陷入了沮丧的递归循环。我正在尝试“bundle 安装”一个项目,但结果是:
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.
所以我尝试这样做:
$ 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
一切顺利!除了当我运行“bundle install”时,我再次被告知我需要先安装“gem install nokogiri -v '1.6.6.2'”。啊啊啊。
mkmf.log 文件表明这是 libxml2 的问题(出人意料)。
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 */
因此,搜索 libxml2(使用“sudo find/-name libxml2”)会显示这些目录,所有这些目录似乎都至少是 2.9.0 或更高版本:
- /usr/include/libxml2
- /usr/local/Cellar/libxml2
- /usr/local/opt/libxml2
那么,是不是libxml2找不到的问题呢?如果是这样,我如何让 bundle install 意识到 nokogiri 已经安装,或者至少能够像“gem install”一样安装它?虽然我想为此找到解决方案,但我真的很想了解“幕后”发生的事情,以便将来进行故障排除。
最佳答案
在我的 Mac OS X 上,我运行了这些命令,问题就解决了。
brew unlink gcc-4.2 # you might not need this step
gem uninstall nokogiri
xcode-select --install
gem install nokogiri
关于ruby - 为什么 "gem"和 "bundle"不使用相同的 libxml2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32466606/