ruby-on-rails - 如何修复 Ruby "no such file to load -- xsd/qname"错误?

标签 ruby-on-rails ruby exception ruby-1.9

我正在尝试运行 FlightXML2 Ruby 库以访问 FlightAware API。 (图书馆的代码在这里:https://github.com/flightaware/flightxml2-client-ruby)

当包含带有“require 'FlightXML2.rb'”行的库文件时,出现以下异常:

LoadError: no such file to load -- xsd/qname
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /...PATH TO GEMS.../lib/FlightXML2.rb:1:in `<top (required)>'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from (irb):2
    from /...PATH TO GEMS.../railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
    from /...PATH TO GEMS.../railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
    from /...PATH TO GEMS.../railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我怀疑这与 Ruby 1.9 和 1.8 之间的不兼容有关,库是为 Ruby 1.8 编写的。有没有办法使它与 Ruby 1.9 一起工作?

最佳答案

为了让 FlightXML2 在我的 Rails 项目中运行,我必须安装“xmlparser”和“soap4r”gem,并添加以下 Gemfile:

gem 'xmlparser'
gem 'soap4r', :git => 'git://github.com/felipec/soap4r.git'

同时添加以下兼容性创可贴:

require 'rexml/document'
require 'continuation'

class Symbol
  def sub(*args)
    to_s.sub(*args)
  end
end

关于ruby-on-rails - 如何修复 Ruby "no such file to load -- xsd/qname"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13597351/

相关文章:

ruby-on-rails - Rails 控制台 - 重新加载!模块中的第三方服务

java - 无法解析的日期异常

C++ 异常 : bad_alloc at memory location

php - 空异常类有什么用途?

ruby-on-rails - Rails - 使@projects 在所有页面加载时可用

css - 设计 CSS 样式

ruby-on-rails - 如何在 Ruby 中创建 Web 套接字客户端?

javascript - 如何将看起来像英文的 Unicode 文本转换为 ASCII?

javascript - 在 javascript 中使用 ruby​​ 方法而不使用 ajax

ruby-on-rails - 将电子邮件中的文本/纯内容转换为普通文本