# How to setup path

**URL:** <https://www.ruby-forum.com/t/how-to-setup-path/117866>\
**Category:** Ruby\
**Created:** [October 21, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866 "2007-10-21T20:21:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [October 21, 2007, 8:21pm UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866/1 "2007-10-21T20:21:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [October 21, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866/2 "2007-10-21T20:40:12Z")

</div>

Hi –

On 21/10/2007, Junkone [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [October 21, 2007, 9:33pm UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866/3 "2007-10-21T21:33:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [October 21, 2007, 9:42pm UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866/4 "2007-10-21T21:42:09Z")

</div>

On 21/10/2007, Michael L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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. 🙂

– Thomas A.

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [October 22, 2007, 1:05pm UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866/5 "2007-10-22T13:05:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Junkone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e274bd/32.png) [@Junkone](https://www.ruby-forum.com/u/Junkone)\
**Post date:** [October 22, 2007, 12:25am UTC](https://www.ruby-forum.com/t/how-to-setup-path/117866/6 "2007-10-22T00:25:27Z")

</div>

Thomas A. wrote:

> On 21/10/2007, Michael L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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. 🙂
> 
> – Thomas A.

Thanks, good to know! 😃
