0

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

无法加载此类文件 -- libxml

如您所见,libxml 已安装在我的 gems 中:

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

4

1 回答 1

2

解决了这个问题:出于某种原因,我有两个不同的 gem 路径指向 ruby​​2.1.0 和 Ruby 2.1.1。在 gemfile 中包含 Ruby '2.1.1' 解决了这个问题

于 2014-08-25T07:25:14.797 回答