2013-08-28 24 views
0

我可以SUCCESSFULLY安装nokigiri使用烦恼与引入nokogiri宝石在山狮使用捆绑

sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.14/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.14/lib 

但是当我运行“捆绑安装”我有libxml2的问题。我的问题是:我如何通过bundler安装nokogiri?

这里是我的“包安装”输出:

Installing nokogiri (1.6.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

    /Users/philswenson/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 
Extracting libxml2-2.8.0.tar.gz into tmp/i686-apple-darwin11/ports/libxml2/2.8.0... OK 
Running 'configure' for libxml2 2.8.0... OK 
Running 'compile' for libxml2 2.8.0... OK 
Running 'install' for libxml2 2.8.0... OK 
Activating libxml2 2.8.0 (from /Users/philswenson/.rvm/gems/[email protected]/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxml2/2.8.0)... 
Extracting libxslt-1.1.26.tar.gz into tmp/i686-apple-darwin11/ports/libxslt/1.1.26... OK 
Running 'configure' for libxslt 1.1.26... OK 
Running 'compile' for libxslt 1.1.26... OK 
Running 'install' for libxslt 1.1.26... OK 
Activating libxslt 1.1.26 (from /Users/philswenson/.rvm/gems/[email protected]/gems/nokogiri-1.6.0/ports/i686-apple-darwin11/libxslt/1.1.26)... 
checking for libxml/parser.h... yes 
checking for libxslt/xslt.h... yes 
checking for libexslt/exslt.h... yes 
checking for iconv_open() in iconv.h... yes 
checking for xmlParseDoc() in -lxml2... no 
----- 
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies. 
----- 
*** extconf.rb failed *** 
Could not create Makefile due to some reason, probably lack of 
necessary libraries and/or headers. Check the mkmf.log file for more 
details. You may need configuration options. 

Provided configuration options: 
    --with-opt-dir 
    --with-opt-include 
    --without-opt-include=${opt-dir}/include 
    --with-opt-lib 
    --without-opt-lib=${opt-dir}/lib 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/Users/philswenson/.rvm/rubies/ruby-1.9.3-p448/bin/ruby 
    --with-zlib-dir 
    --without-zlib-dir 
    --with-zlib-include 
    --without-zlib-include=${zlib-dir}/include 
    --with-zlib-lib 
    --without-zlib-lib=${zlib-dir}/lib 
    --with-iconv-dir 
    --without-iconv-dir 
    --with-iconv-include 
    --without-iconv-include=${iconv-dir}/include 
    --with-iconv-lib 
    --without-iconv-lib=${iconv-dir}/lib 
    --with-xml2-dir 
    --without-xml2-dir 
    --with-xml2-include=${xml2-dir}/include 
    --with-xml2-lib 
    --without-xml2-lib=${xml2-dir}/lib 
    --with-xslt-dir 
    --without-xslt-dir 
    --with-xslt-include 
    --without-xslt-include=${xslt-dir}/include 
    --with-xslt-lib 
    --without-xslt-lib=${xslt-dir}/lib 
    --with-libxslt-config 
    --without-libxslt-config 
    --with-pkg-config 
    --without-pkg-config 
    --with-libxml-2.0-config 
    --without-libxml-2.0-config 
    --with-libiconv-config 
    --without-libiconv-config 
    --with-xml2lib 
    --without-xml2lib 


Gem files will remain installed in /Users/philswenson/.rvm/gems/[email protected]/gems/nokogiri-1.6.0 for inspection. 
Results logged to /Users/philswenson/.rvm/gems/[email protected]/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out 

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

有人能指出我在正确的方向?

谢谢!

+0

'libxml2 is missing'所以你需要安装它 –

+2

你不应该用本地用户安装的RVM使用sudo。你用第一个命令安装了nokogiri 1.6.0吗? – sevenseacat

回答

1

如果您使用RVM或类似的Ruby版本管理器,则不应该使用sudo

+0

原来在最初的nokogiri安装中删除“sudo”解决了这个问题。所以先运行“gem install nokogiri(带参数)”。然后运行“捆绑安装”和bundler工作正常。它看起来好像我应该能够告诉打包程序在哪里,但我没有成功地将params传递给bundler。 –

+0

sudo rvm将gem安装到根目录的gem路径,而不是当前用户IIRC。它也可能使用另一个ruby,就像系统框架一样。 – Barry

-1

错误消息显示你已经错过了的libxml2所以首先,安装libxml的的libxslt通过自制软件,比如:

brew install libxml2 libxslt 
brew link libxml2 libxslt 

,然后安装引入nokogiri

gem install nokogiri 
+0

我应该更清楚。我可以通过gem install nokogiri成功安装(但是我必须指定参数 - --with-xml2-include =/usr/local/Cellar/libxml2/2.9.1/include/libxml2 ...但是当我尝试通过Bundler安装,它会失败,这是我的问题 - 我如何使它与捆绑器一起工作? –

+0

链接libxml2或libxslt并不好,它们只有几个原因。因为NG迫使你不使用NOKOGIRI_USE_SYSTEM_LIBRARIES = 1来使用它们的缩放。 – Barry

0

这适用于最新的Xcode CLT,山狮和小牛,以及引入nokogiri 1.6.1

临时解决方案0

正是引入nokogiri的补丁酿造配方和的libxslt的libxml2

curl -L https://gist.githubusercontent.com/steakknife/8969368/raw/install_nokogiri_brew_osx.sh | bash 

if you dont trust https pipe to shell, here's the script raw url[gist url]

更快的方式,并提供一个已知好的,只有桶的副本libiconv和nokogiri的libxml2和libxslt。系统libxml2未被触及。

临时溶液1

这需要几分钟和安装时吃掉100 MIB +。

gem install nokogiri 

无论哪种方式,libxml2的需要变得更加稳定,或者它是一个事实上的叉子和大家更多的工作。

不要打扰链接libxml2或libxslt,sudo什么,或者安装libiconv,这些都是不必要的和脆弱的。