From: Mark Bush Date: 2008-02-21T22:38:35+09:00 Subject: Re: How to get the directory of the current script? > File.dirname(__FILE__) will give you the current file's path. The current file may be accessed with a relative path. If you need the absolute path, make sure you expand it: File.expand_path(File.dirname(__FILE__)) > Also, if I have a module, within a function, how do I get the parent > directory (full path) of that module? If __FILE__ is used in that module, it will refer to the file containing that module. If the module is under your control, you can add a method that provides this: module MyModule def this_file __FILE__ end end Otherwise, as has been noted, since a module name does not have to have any relation to the filename it is in, there is no way (AFAIK) to find the file containing a particular module unless you open the current file and parse for any require or load calls (recursively using the current environment for searching for files) and look for the module declaration line. (Note that a file may have been required using a path, so you must parse the current script to find where files have been located.) Of course, a module could have content added in multiple files... -- Posted via http://www.ruby-forum.com/.