how to setup path

T

Thomas Adam

Hi --

how to setup the ruby path that my code can look at runtime for the
libraries.

If it's a non-standard path, try:

$LOAD_PATH.unshift( '/some/path/to/wherever' )
require 'mylib'

-- Thomas Adam
 
M

Michael Linfield

Junkone said:
ruby path

correct me if im wrong but wouldnt you just use the shebang? Of course
this would be if your libraries were in fact still in the default ruby
installation folders, the only reason you would need to use this would
be if u moved the entire ruby folder elsewhere. Sorry Thomas if this is
what u were explaining.

#!/path/name/here
 
T

Thomas Adam

correct me if im wrong but wouldnt you just use the shebang? Of course
this would be if your libraries were in fact still in the default ruby
installation folders, the only reason you would need to use this would
be if u moved the entire ruby folder elsewhere. Sorry Thomas if this is
what u were explaining.

Changing the shebang would only change where to find the ruby
interpreter, _not_ where Ruby itself looked for its libraries. Of
course, there's every need during development to have various files
under some non-standard location (such as
~/projects/ruby/my_new_library) -- it is at this point that adding to
$LOAD_PATH is the right thing to do. :)

-- Thomas Adam
 
M

Michael Linfield

Thomas said:
Changing the shebang would only change where to find the ruby
interpreter, _not_ where Ruby itself looked for its libraries. Of
course, there's every need during development to have various files
under some non-standard location (such as
~/projects/ruby/my_new_library) -- it is at this point that adding to
$LOAD_PATH is the right thing to do. :)

-- Thomas Adam

Thanks, good to know! :D
 
P

Paul

C:\Documents and Settings\user>irb
irb(main):001:0> $:
=> ["c:/ruby/lib/ruby/site_ruby/1.8", "c:/ruby/lib/ruby/site_ruby/1.8/
i386-msvcr
t", "c:/ruby/lib/ruby/site_ruby", "c:/ruby/lib/ruby/1.8", "c:/ruby/lib/
ruby/1.8/
i386-mswin32", "."]
irb(main):002:0> $: << 'c:/mylib'
=> ["c:/ruby/lib/ruby/site_ruby/1.8", "c:/ruby/lib/ruby/site_ruby/1.8/
i386-msvcr
t", "c:/ruby/lib/ruby/site_ruby", "c:/ruby/lib/ruby/1.8", "c:/ruby/lib/
ruby/1.8/
i386-mswin32", ".", "c:/mylib"]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top