使nokogiri使用较新版本的libxml2 [英] Getting nokogiri to use a newer version of libxml2

查看:73
本文介绍了使nokogiri使用较新版本的libxml2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直试图在我的计算机(Mountain Lion)上安装Nokogiri以便与rspec和capybara一起使用,但是对于我来说,我无法使其正常运行.

I've been trying to get Nokogiri installed on my computer (Mountain Lion) to use with rspec and capybara, but for the life of me, I can't get it to run properly.

据我所知,问题出在使用错误版本的libxml2的nokogiri.到目前为止,我已经尝试使用Homebrew卸载并重新安装libxml2(确保它是最新版本),使用捆绑软件卸载并重新安装nokogiri,并指定安装nokogiri gem时Homebrew安装的libxml2文件的确切路径.我最近的安装说明如下:

From what I can tell, the issue is with nokogiri using the wrong version of libxml2. I've so far tried uninstalling and reinstalling libxml2 using Homebrew (making sure it's the most recent one), uninstalling and reinstalling nokogiri using bundle, and specifying the exact path to the libxml2 files that Homebrew installed when installing the nokogiri gem. My most recent install instructions looked like this

sudo gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.0/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.0/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28

所有这些位置确实与安装工具的位置相对应.但是,在运行bundle exec rspec spec/requests/static_pages.rb时,我仍然得到以下输出:

where all of those locations do correctly correspond to the locations where the tools are installed. However, upon running bundle exec rspec spec/requests/static_pages.rb, I still get this output:

/Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri.rb:28:in `require': dlopen(/Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /usr/local/lib/libxml2.2.dylib (LoadError)
Referenced from: /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle
Reason: Incompatible library version: nokogiri.bundle requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0 - /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri/nokogiri.bundle
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/nokogiri-1.5.9/lib/nokogiri.rb:28:in `<top (required)>'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `each'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:70:in `block in require'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `each'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler/runtime.rb:59:in `require'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286@global/gems/bundler-1.3.4/lib/bundler.rb:132:in `require'
    from /Users/alex/Sites/harbingernews/config/application.rb:7:in `<top (required)>'
    from /Users/alex/Sites/harbingernews/config/environment.rb:2:in `require'
    from /Users/alex/Sites/harbingernews/config/environment.rb:2:in `<top (required)>'
    from /Users/alex/Sites/harbingernews/spec/spec_helper.rb:3:in `require'
    from /Users/alex/Sites/harbingernews/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/alex/Sites/harbingernews/spec/requests/static_pages_spec.rb:1:in `require'
    from /Users/alex/Sites/harbingernews/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `block in load_spec_files'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `map'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/configuration.rb:746:in `load_spec_files'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/command_line.rb:22:in `run'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:69:in `run'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p286/gems/rspec-core-2.9.0/lib/rspec/core/runner.rb:10:in `block in autorun'

我已经尝试了所有在网上找到的步骤(大多数参考资料都在构建和加载libxml2的不同版本,例如此步骤,但还没有成功.我的Gemfile和Gemfile.lock可以在此处找到.完全可以帮助我,我将非常感激.我无法在网上找到其他任何与此问题有关的案例.

I've tried all the steps that I've found online (most reference building and loading different versions of libxml2, like this one, but have had no success yet. My Gemfile and Gemfile.lock can be found here. If anyone can help me out at all, I would really appreciate it. I haven't been able to find any other cases online with this problem.

推荐答案

为了明确起见,Phrogz的评论帮助了我很多.我按照他链接的说明进行操作,

Just to make it clear, Phrogz's comment helped me out quite a bit. I followed the instructions that he linked to, the What to do if libxml2 is being a jerk? page on Nokogiri's Github page. I ended up using Macports instead of Homebrew, and I'm not sure if that's what made the difference (I had tried many of those steps already) but one way or another, it seems to be working alright now.

这篇关于使nokogiri使用较新版本的libxml2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆