From: Erik Veenstra Date: 2005-08-11T20:11:10+09:00 Subject: Re: require and relative paths > I found a solution, but I think it's a bit clumpsy: > > $: << File.dirname(File.expand_path(__FILE__)) > $: << File.dirname(File.expand_path(__FILE__)).sub(/(.*)\/\w+/, '\1') > require "Classes/Window" > require "Modules/InstanceCounter" <-- no "../" needed anymore I couldn't do it clumpsier...:) This is what I would do: f1 = File.expand_path(__FILE__) d1 = File.dirname(f1) d2 = File.dirname(d1) $: << d1 $: << d2 require "Classes/Window" require "Modules/InstanceCounter" If you want to add more directories, upto the root, use this: entry = File.expand_path(__FILE__) while (not $:.include?(entry = File.dirname(entry))) $: << entry end require "Classes/Window" require "Modules/InstanceCounter" (Just kidding...) Just don't use "./" or "../" or any other "relative" references to a file in a require statement. Trying setting up $: correctly instead and feed require the name of the library instead of filenames. gegroet, Erik V. - http://www.erikveen.dds.nl/