libxml / nokogiri无法正常工作:无法加载此类文件 - libxml rails

时间:2014-08-20 19:45:44

标签: ruby-on-rails ruby xml nokogiri libxml-ruby

我正在尝试在我的rails应用程序中使用libxml。但是我得到了错误:

  

无法加载此类文件 - libxml

正如您所见,我的宝石中安装了libxml:

Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.0
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.1
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.1
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.1
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.1
Using activemodel 4.1.1
Using arel 5.0.1.20140414130214
Using activerecord 4.1.1
Using bundler 1.6.2
Using coffee-script-source 1.7.1
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.1
Using coffee-rails 4.0.1
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.1
Using libxml-ruby 2.7.0
Using pg 0.17.1
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.1
Using rdoc 4.1.1
Using sass 3.2.19
Using sass-rails 4.0.3
Using sdoc 0.4.1
Using spring 1.1.3
Using turbolinks 2.2.3
Using uglifier 2.5.3
Your bundle is updated!

我尝试在我的控制器类中使用它:

require 'libxml'
  def import
    some code that it doesnt even reach
  end

有谁知道我能做些什么让它发挥作用?

在Mac OSX 10.9.x上使用它 - Rails 4 - Ruby 2.1.1

更新 我按照http://nokogiri.org/tutorials/installing_nokogiri.html中的步骤安装了nokogiri而不是libxml 并将gem添加到gem文件中:gem'nokogiri'

遗憾的是,加载错误仍然存​​在,但现在对于nokogiri:无法加载此类文件 - nokogiri

1 个答案:

答案 0 :(得分:2)

解决了问题:由于某种原因,我有两个不同的gem路径指向ruby2.1.0和Ruby 2.1.1。在gemfile中包含Ruby'2.1.1'解决了问题

相关问题