但我只收到
./chronic.rb:3: uninitialized constant Chronic (NameError)
from E:/prog/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from E:/prog/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from chronic.rb:1
如果我运行此代码
require 'chronic'
puts Chronic.parse("yesterday")
puts "Tomorrow = #{Chronic.parse('tomorrow')}"
puts "Today = #{Chronic.parse('today')}"
puts "yesteday = #{Chronic.parse('yesteday')}"
puts "2 days ago = #{Chronic.parse('2 days ago')}"
puts "2 months ago = #{Chronic.parse('2 months ago')}"
答案 0 :(得分:2)
包含名为chronic.rb
的测试代码的文件或当前目录中是否有另一个名为chronic.rb
的文件?如果是这样,请尝试重命名。
您的require 'chronic'
语句正在从当前目录加载文件chronic.rb
,而不是在gem中搜索该文件。