Requiring external libraries directly

I want to put all the external libraries I'm using in my project in a
folder and require directly from there instead of installing the gem in
ruby.

MyProject folder
   ExternalLibraries folder
       Watir
       rexml
       oci8
       ...
   mycode requiring the libraries in ExternalLibraries if it's needed

Is that possible?

···

--
Posted via http://www.ruby-forum.com/.

Any idea???

···

--
Posted via http://www.ruby-forum.com/.

Mario Ruiz wrote:

MyProject folder
   ExternalLibraries folder
       Watir
       rexml
       oci8
       ...
   mycode requiring the libraries in ExternalLibraries if it's needed

Just add following string into your code (before require statements)

$:.unshift File.join(File.dirname(__FILE__), "..", "ExternalLibraries
folder")
require ...

this will add ExternalLibraries folder to the ruby load path.

Regards,
arkadi4

···

--
Posted via http://www.ruby-forum.com/.

But I'll need the gem file in the external library folder or what??

···

--
Posted via http://www.ruby-forum.com/.

Al Og wrote:

$:.unshift File.join(File.dirname(__FILE__), "..", "ExternalLibraries folder")
require ...

Suggestion:

Instead of:

   File.dirname(__FILE__)

use this:

   File.dirname(File.expand_path(__FILE__))

The protects you in case of Dir.chdir.

···

--
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Don't trim context, we don't know what you're talking about when you do that.

···

On Dec 21, 2007, at 06:59 AM, Mario Ruiz wrote:

I want to put all the external libraries I'm using in my project in a
folder and require directly from there instead of installing the gem in
ruby.

But I'll need the gem file in the external library folder or what??

If you're sourcing the files you want from gems, what's wrong with using gems? It does everything you want without any extra hassle of figuring out how to get your load path correct.