Ruby'require'错误:无法加载此类文件 [英] Ruby 'require' error: cannot load such file
本文介绍了Ruby'require'错误:无法加载此类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文件main.rb,内容如下:
I've one file, main.rb with the following content:
require "tokenizer.rb"
tokenizer.rb文件位于相同目录中,其内容为:
The tokenizer.rb file is in the same directory and its content is:
class Tokenizer
def self.tokenize(string)
return string.split(" ")
end
end
如果我尝试运行main.rb,则会出现以下错误:
If i try to run main.rb I get the following error:
C:\Documents and Settings\my\src\folder>ruby main.rb
C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- tokenizer.rb (LoadError)
from C:/Ruby193/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require '
from main.rb:1:in `<main>'
我只是注意到,如果我使用load
而不是require
,一切都会很好.这可能是什么问题?
I just noticed that if I use load
instead of require
everything works fine. What may the problem be here?
推荐答案
我刚刚尝试过,它可与require "./tokenizer"
一起使用.希望这会有所帮助.
I just tried and it works with require "./tokenizer"
. Hope this helps.
这篇关于Ruby'require'错误:无法加载此类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文