# Newbie question: Where to put library .rb files?

**URL:** <https://www.ruby-forum.com/t/newbie-question-where-to-put-library-rb-files/152507>\
**Category:** Ruby\
**Created:** [November 4, 2008, 6:24pm UTC](https://www.ruby-forum.com/t/newbie-question-where-to-put-library-rb-files/152507 "2008-11-04T18:24:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [November 4, 2008, 6:24pm UTC](https://www.ruby-forum.com/t/newbie-question-where-to-put-library-rb-files/152507/1 "2008-11-04T18:24:58Z")

</div>

At our site, newly started using Ruby, we’re now starting to get code  
we’d like to make generally available via ‘require’. What is the  
standard location/method for doing this? Can it be done in such a  
manner that rdoc and ri documentation is made available to the site,  
preferably integrated with the rest of the ruby docs on this site?

Thanks,  
Ken McDonald

---

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [November 5, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/newbie-question-where-to-put-library-rb-files/152507/2 "2008-11-05T16:35:28Z")

</div>

I don’t have a direct answer to your question - but what you’re looking  
for is how to create a gem…  
Best of luck on your research!

–Aldric

---

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [November 5, 2008, 10:20pm UTC](https://www.ruby-forum.com/t/newbie-question-where-to-put-library-rb-files/152507/3 "2008-11-05T22:20:52Z")

</div>

On Nov 4, 12:22 pm, Kenneth McDonald  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> At our site, newly started using Ruby, we’re now starting to get code  
> we’d like to make generally available via ‘require’. What is the  
> standard location/method for doing this? Can it be done in such a  
> manner that rdoc and ri documentation is made available to the site,  
> preferably integrated with the rest of the ruby docs on this site?
> 
> Thanks,  
> Ken McDonald

The place you want is ruby\lib\ruby\site\_ruby.

For example, I have my home-grown utility Search.rb stored there,  
which defines a Search class. Then a Ruby program stored anywhere can  
simply include:

require ‘search’ # case-insensitive on WinXP, e.g.  
s = Seach.new # etc.

HTH,  
Richard

---

<div class="post-metadata">

**Author:** ![Kenneth\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dc4da7/32.png) [@Kenneth\_McDonald](https://www.ruby-forum.com/u/Kenneth_McDonald)\
**Post date:** [November 6, 2008, 1:20am UTC](https://www.ruby-forum.com/t/newbie-question-where-to-put-library-rb-files/152507/4 "2008-11-06T01:20:39Z")

</div>

Kenneth McDonald wrote:

> At our site, newly started using Ruby, we’re now starting to get code  
> we’d like to make generally available via ‘require’. What is the  
> standard location/method for doing this? Can it be done in such a  
> manner that rdoc and ri documentation is made available to the site,  
> preferably integrated with the rest of the ruby docs on this site?
> 
> Thanks,  
> Ken McDonald

To see what your current config is set to cut-n-paste this into  
irb:

puts “ruby load directories”  
puts  
$:.each do |e|  
puts e  
end

Since I work across a variety of platforms, I prefer to set the  
RUBYLIB environment variable on each of my systems to a directory  
of my choosing. This directory is added to load paths in $:
