2011-09-25 36 views
0

我不明白爲什麼會出現此錯誤。我有一個名爲hello.rb的文件,它位於"C/Ruby192/bin/hello.rb"如何解決irb中的這個負載錯誤問題?

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>' 

如果你能解決這個問題,我會非常感激。

回答

3

fine manual

負載(文件名,渦卷=假)→真
載荷和在文件的文件名執行Ruby程序。如果文件名未解析爲絕對路徑,則在$:中列出的庫目錄中搜索該文件。

"hello.rb"不是絕對路徑,以便load看起來通過$:找到它的庫目錄。據推測,'C/Ruby192/bin'不在$:(或'.'不在$:,如果你在C/Ruby192/bin/已經)。嘗試指定完整路徑:

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