开发者

How do I solve this load error problem in irb?

I can't understand why this error occurs. I have a file named hello.rb, it is in "C/Ruby192开发者_Python百科/bin/hello.rb".

irb(main):005:0>load("hello.rb")  
Load Error: no such file to load -- hello.rb  
    from(irb):5:in`load'  
    from(irb):5  
    from C:/Ruby192/bin/irb:12:in`<main>'

I would be very appreciative if you could solve this problem.


From the fine manual:

load(filename, wrap=false) → true
Loads and executes the Ruby program in the file filename. If the filename does not resolve to an absolute path, the file is searched for in the library directories listed in $:.

Your "hello.rb" is not an absolute path so load looks through $: to find it in the library directories. Presumably, 'C/Ruby192/bin' isn't in $: (or '.' isn't in $: if you're in C/Ruby192/bin/ already). Try specifying the full path:

> load('C/Ruby192/bin/hello.rb')
> load('./hello.rb') # If you're in C/Ruby192/bin/ already
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜