开发者

Why would yaml be unavailable in production?

On my OS X development system:

$ ruby --version
ruby 1.8.6 (2007-03-13 开发者_如何学Gopatchlevel 0) [universal-darwin8.0]

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

On CentOS 5.3 production system:

$ 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

Anything I can do about that NoMethodError?

Why would yaml be unavailable. Isn't it part of the core Ruby libraries?


Returning false means that the loading was successful or was already done. If it couldn't be loaded, it'd raise an exception instead.


It is part of the Ruby core libraries, but I'm not sure what gets bundled up with Ruby Enterprise Edition. Check that yaml.rb is inside your $LOAD_PATH. For example, try this in irb:

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

On OS X it will produce something like:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜