From: Tobias Reif Date: 2001-10-30T19:48:43+09:00 Subject: [ruby-talk:23828] Re: require NQXML Hi, using$:.unshift, it works. (if the FooBar lib is near the working dir). I just unshift the path mising between the programs' dir, then I get the version that's in this path, and the require lines in FooBar lib (like in NQXML) find the correct versions too, because the correct path to the correct version is unshifted in $:. Peachy. ----- $:.unshift "foo/1.1.2/" require 'foo/1.1.2/foo/Foo' f = Foo.new puts f.my_version, f.required_files_version ----- 1.1.2 1.1.2 But now I'd like to be able to just move the lib/NQXML to site_ruby, without having to change my program; but with the current solution I have to: ----- $:.unshift "/cygdrive/c/RUBY/lib/ruby/site_ruby/1.6/foo/9.9.9/" require 'foo/9.9.9/foo/Foo' f = Foo.new puts f.my_version, f.required_files_version ----- 9.9.9 9.9.9 but that can't be the idea. If I just say ----- $:.unshift "foo/9.9.9/" require 'foo/9.9.9/foo/Foo' f = Foo.new puts f.my_version, f.required_files_version ----- I get ----- /cygdrive/c/RUBY/lib/ruby/site_ruby/1.6/foo/9.9.9/foo/Foo.rb:1:in `require': No such file to load -- foo/Bar.rb (LoadError) from /cygdrive/c/RUBY/lib/ruby/site_ruby/1.6/foo/9.9.9/foo/Foo.rb:1 from require_foo.rb:5:in `require' from require_foo.rb:5 ----- because the 9.9.9 version is not near the working dir, but in site_ruby. I guess I need a variable that represents the missing link between dirs on the path, and those required, no matter where the wd is. Also I think there should be flexible, easy to use solution. Tobi P.S. Here are some files involved: in [working_dir]/foo/1.1.2/foo ---Foo.rb--- require 'foo/Bar.rb' class Foo def my_version "1.1.2" end def required_files_version Bar.new.my_version end end ----- ---Bar.rb--- class Bar def my_version "1.1.2" end end --- in C:/ruby/lib/ruby/site_ruby/1.6/foo/9.9.9/foo -----Bar.rb--- class Bar def my_version "9.9.9" end end ----- ----Foo.rb--- require 'foo/Bar.rb' class Foo def my_version "9.9.9" end def required_files_version Bar.new.my_version end end ---