From: Robert Klemme Date: 2010-02-02T19:08:56+09:00 Subject: Re: Refining the use of file joins or file expand_path 2010/2/1 Alpha Blue : > So, am I correct to assume that require is realistically for relative > paths and load should be formally used with absolute paths?  Given the > issue that just occurred with a file that was created and is heavily > used by other WxRuby people, wouldn't it be more prudent to use only > absolute paths with load statements?  Or, is this more of a case by case > basis, depending on whether or not you are packaging/porting your code? I would make a different distinction: "require" is for loading library code (libs as parts of the installation, self written libs as well as gems). "load" is for explicitly forcing a file load and execution at a define place in the source code. Now, I don't know Ocra and hence I can't say anything about it. My approach is this: I have environment variable RUBYLIB set to an absolute path where I place my own written libs ("${HOME}/lib/ruby" in my case). I don't have any gems installed on the system I am working on so no requirements there. But generally the usage model of "require" is that there is a list of entry points (partly built into the interpreter, partly provided by the user e.g. via $RUBYLIB) which are searched - which also means you generally use only relative paths with require. This is also true for recursive requires - which can be autoloads as well. See here for an example: http://github.com/rklemme/muppet-laboratories/blob/master/lib/animal.rb I cannot remember when I used "load" the last time - probably because I do not generate code most of the time and my programs are not that large that I would need to executed code in a file potentially multiple times. I'd say, whenever you do this you need to make sure you provide the path in a way that the script can be found. If you generate it, you'll have the file name in a variable anyway and so you can use that. If you need to find it based on different criteria you need to do whatever it takes to make the path correct. Turning back to your original example: it looks like what you really want is to do "require 'ui'" and have a file "ui.rb" located somewhere in your library path which then consists mainly (or only) of "require 'ui/a'" lines. "a.rb" then would be placed in directory /ui, i.e. below the directory which contains file "ui.rb". Hope that helps. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/