How to setup path

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

Hi –

On 21/10/2007, Junkone [email protected] wrote:

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

Junkone wrote:

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

On 21/10/2007, Michael L. [email protected] wrote:

Junkone wrote:

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.

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. :slight_smile:

– Thomas A.

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”]

Thomas A. wrote:

On 21/10/2007, Michael L. [email protected] wrote:

Junkone wrote:

ruby path

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. :slight_smile:

– Thomas A.

Thanks, good to know! :smiley:

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