【问题标题】:Why would yaml be unavailable in production?为什么 yaml 在生产中不可用?
【发布时间】:2009-11-24 23:29:18
【问题描述】:

在我的 OS X 开发系统上:

$ ruby --version
ruby 1.8.6 (2007-03-13 patchlevel 0) [universal-darwin8.0]

$ script/console
Loading development environment (Rails 2.3.4)
>> require 'yaml'
=> []

在 CentOS 5.3 生产系统上:

$ script/console production
Loading production environment (Rails 2.3.4)
/opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/base.rb:1959:in `method_missing':NoMethodError: undefined method `define_index' for #<Class:0x2e6f7b0>
>> require 'yaml'
=> false

我能对 NoMethodError 做些什么?

为什么 yaml 不可用。它不是核心 Ruby 库的一部分吗?

【问题讨论】:

    标签: ruby-on-rails ruby


    【解决方案1】:

    返回 false 表示加载成功或已经完成。如果无法加载,则会引发异常。

    【讨论】:

      【解决方案2】:

      它是 Ruby 核心库的一部分,但我不确定 Ruby 企业版捆绑了什么。检查 yaml.rb 是否在您的 $LOAD_PATH 中。例如,在 irb 中试试这个:

      $LOAD_PATH.collect { |path| File.join(path, 'yaml.rb') }.find { |path| File.exist?(path) }
      

      在 OS X 上,它会产生类似:

      => "/opt/local/lib/ruby/1.8/yaml.rb"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-08-12
        • 2019-05-16
        • 1970-01-01
        • 2015-05-04
        • 2018-10-13
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多