From: Jean-denis Vauguet Date: 2010-03-23T14:39:07+09:00 Subject: require, from within lib, files located under the local path Hi. Here's an issue I've not been able to solve for some time now. Let's say I designed a tiny library, following a standard structure: $ tree . |-- LICENSE |-- README.md |-- Rakefile |-- VERSION |-- lib | |-- mylib | | `-- core.rb | `-- metamorphosis.rb |-- metamorphosis.gemspec `-- test Using Jeweler to build and install the gem (successfully), it goes into (for instance): home/YOU/.rvm/gems/ruby-1.9.1-p378/gems/mylib-0.1.0/ The purpose of mylib involves allowing the user who will eventually perform a require 'mylib', to create, along the file.rb performing the require, a folder (let's call it mylib_stuff). So the user sets up the following structure: $ tree . |-- main.rb `-- mylib_stuff |-- a_piece_of stuff.rb |-- ... `-- another_piece_of_stuff.rb The core.rb file needs to use what's inside mylib_stuff/*. Using the standard technique: require File.expand_path("../../mylib_stuff", __FILE__), you end up with the following error: no such file to load -- /home/YOU/.rvm/gems/ruby-1.9.1-p378/gems/mylib-0.1.0/mylib_stuff/[foobar] That's because __FILE__ is core.rb. So what I'd like to do is passing require a path which would be aware of the location the gem mylib is used from, so it'll access this particular path. Another script using mylib would trigger different require statements in core.rb, involving it's very own mylib_stuff local directory. Thank you! -- Posted via http://www.ruby-forum.com/.