Snow Kakadu
Snow Kakadu

Reputation: 67

Addind new directory to $LOAD_PATH in Ruby 2.0.0

Having gone through several posts on this issue I still can't add new directory to $LOAD_PATH. I use Ubuntu 12. My $LOAD_PATH is:

2.0.0-p247 :002 > puts $LOAD_PATH
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby/2.0.0
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby/2.0.0/x86_64-linux
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-linux
 => nil 

How to add '/home/ajax/Ruby/Projects' to $LOAD_PATH through terminal?

Upvotes: 1

Views: 847

Answers (3)

Simone Carletti
Simone Carletti

Reputation: 176552

From Add $LOAD_PATH externally

RUBYLIB environment variable is a colon separated list of paths which ruby will prepend the the standard LOAD_PATH. ruby -I path on the command line is also the same as $LOAD_PATH.unshift 'path' in your code. Ruby will also process options from environment var RUBYOPT.

Upvotes: 0

Holger Just
Holger Just

Reputation: 55888

You can add additional entries to the $LOAD_PATH as a command line parameter to your ruby (or irb) command using the -I argument (which can be used multiple times)

$ ruby -I '/home/ajax/Ruby/Projects' -e 'puts $LOAD_PATH'
/home/ajax/Ruby/Projects
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby/2.0.0
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby/2.0.0/x86_64-linux
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/vendor_ruby
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0
/home/ajax/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/x86_64-linux

Upvotes: 1

Adeptus
Adeptus

Reputation: 683

in your terminal

export RUBYLIB=/home/ajax/Ruby/Projects

Upvotes: 0

Related Questions