开发者

Why does Ruby find all of my classes except for one named Config?

I have a Ruby program that runs fine on Linux. I'm trying it out on Windows 7 right now, and it should be fine since it only uses two libraries that installed without issues.

The error I'm getting is related to my own code. I have a file called config.rb, which has a class named Config. It has some values that you can change. Sounds pretty harmless.开发者_开发问答

However, I'm unable to require this class. Ruby gems custom require (i dont use gems at all) is not finding my file. What is going on here?

<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- config (LoadError)
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from apitester.rb:9:in `<main>'

On line 9 of apitester.rb I have:

require 'config'

and config.rb is that simple class, in the same folder.


Try with the following in Ruby 1.8:

require File.join(File.dirname(__FILE__), 'config')

or if you are using in Ruby 1.9:

require_relative 'config'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜