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?

Any idea???

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

Mario R. 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

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 R. 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.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs