# Directory structure of a Ruby installation, including the pa

**URL:** <https://www.ruby-forum.com/t/directory-structure-of-a-ruby-installation-including-the-pa/55791>\
**Category:** Ruby\
**Created:** [March 23, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/directory-structure-of-a-ruby-installation-including-the-pa/55791 "2006-03-23T21:32:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![randy\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/258eb7/32.png) [@randy\_k](https://www.ruby-forum.com/u/randy_k)\
**Post date:** [March 23, 2006, 9:32pm UTC](https://www.ruby-forum.com/t/directory-structure-of-a-ruby-installation-including-the-pa/55791/1 "2006-03-23T21:32:00Z")

</div>

Restart:

For a variety of reasons, I’m trying to get a better understanding of  
how a  
Ruby installation is laid out on disk. Maybe the best way to explain  
what I  
mean is by giving some of the specific questions I have. (Maybe these  
are  
not so much Ruby specific, but maybe generic to a typical language  
install.)

BTW, this is for a Linux installation.

Statements and questions intermixed:

- I installed Ruby 1.8.4 by compiling from the source tarball, and  
started  
by untar-ing it in, essentially, my home directory.

- The ruby executable is installed in /usr/local/bin/ruby, and a  
bunch  
of .rb files are installed in /usr/local/lib/ruby/1.8/. I didn’t have  
any  
choice in the matter, so I assume that’s a good location.

- Many, maybe all, of those same .rb files are in what I’ll call my  
install  
directory (tree) (in my home directory). Now that ruby is installed can  
I  
delete all that stuff in my home directory (that came from untar-ing the  
tarball)?

- If I go to install another “library” (is that the right word for  
those .rb files), specifically for the tkHTML widget, I presume I should  
install that in the /usr/local/lib/ruby/1.8/ directory (or a  
subdirectory)?

- When I do a require, like require ‘tk’, the tk.rb file is looked  
for  
in /usr/local/lib/ruby/1.8/?

- If tk.rb were in some subdirectory of /usr/local/lib/ruby/1.8/ (say  
sub,  
for example), then the require statement to have it loaded would be  
require  
‘sub/tk’?

- As long as all of my library .rbs are in the  
/usr/local/lib/ruby/1.8/  
tree, I don’t have to set the RUBYLIB environment variable?

Well, actually, going through the questions like that, I suspect I  
understand  
more than I thought (assuming all or most of the answers above are yes  
(or  
somehow positive)).

If I’m grossly wrong, maybe it would help me to have a link to an  
explanation  
of how all the above should work/fit together.

Thanks,  
Randy K.

---

<div class="post-metadata">

**Author:** ![randy\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/258eb7/32.png) [@randy\_k](https://www.ruby-forum.com/u/randy_k)\
**Post date:** [March 23, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/directory-structure-of-a-ruby-installation-including-the-pa/55791/2 "2006-03-23T22:03:50Z")

</div>

On Fri, 2006-03-24 at 05:31 +0900, Randy K. wrote:

> Restart:
> 
> For a variety of reasons, I’m trying to get a better understanding of how a  
> Ruby installation is laid out on disk. Maybe the best way to explain what I  
> mean is by giving some of the specific questions I have. (Maybe these are  
> not so much Ruby specific, but maybe generic to a typical language install.)

I think Ruby generally follows the standard Linux/FHS layout, together  
with layout used by other languages (I know Perl has site\_perl, for  
example).

> 

I don’t think it really matters, but if I’m installing something  
system-wide I tend to keep the source in /usr/local/src , while if I’m  
installing for just me I keep it in ~/src.

> - The ruby executable is installed in /usr/local/bin/ruby, and a bunch  
> of .rb files are installed in /usr/local/lib/ruby/1.8/. I didn’t have any  
> choice in the matter, so I assume that’s a good location.

It’s the default (and standard) location. For a systemwide install I’d  
call it ‘the right location’, but bear in mind that you can change it  
during the configure step (try passing --help to the ruby configure  
script). I (and I guess many others) have a site-wide Ruby 1.8 install,  
and a 1.9 snapshot installed in my home directory, also with a different  
program suffix (ruby9, irb9, ri9, etc) which is handled with options to  
the configure script.

> - Many, maybe all, of those same .rb files are in what I’ll call my install  
> directory (tree) (in my home directory). Now that ruby is installed can I  
> delete all that stuff in my home directory (that came from untar-ing the  
> tarball)?

I guess so, but I wouldn’t. I guess if you’re absolutely sure you won’t  
want to do a quick rebuild, or look something up in the source, then you  
could delete them if you wished.

> - If I go to install another “library” (is that the right word for  
> those .rb files), specifically for the tkHTML widget, I presume I should  
> install that in the /usr/local/lib/ruby/1.8/ directory (or a subdirectory)?

That’s not recommended practice - that directory holds ruby and the  
standard library, additional stuff is usually placed  
in /usr/local/lib/ruby/site\_ruby/1.8 I think. Most libraries come with a  
setup.rb that’ll install there automatically.

> - When I do a require, like require ‘tk’, the tk.rb file is looked for  
> in /usr/local/lib/ruby/1.8/?

$ ruby -e ‘p $LOAD\_PATH’  
["/usr/local/lib/ruby/site\_ruby/1.8",  
“/usr/local/lib/ruby/site\_ruby/1.8/i686-linux”,  
“/usr/local/lib/ruby/site\_ruby”,  
“/usr/local/lib/ruby/1.8”,  
“/usr/local/lib/ruby/1.8/i686-linux”,  
“.”]

> - If tk.rb were in some subdirectory of /usr/local/lib/ruby/1.8/ (say sub,  
> for example), then the require statement to have it loaded would be require  
> ‘sub/tk’?

Yes. I think ‘require’ paths are tried relative to the paths in  
$LOAD\_PATH, in order.

> - As long as all of my library .rbs are in the /usr/local/lib/ruby/1.8/  
> tree, I don’t have to set the RUBYLIB environment variable?

Not as far as I’m aware, I don’t think I ever have.

Hope that helps,

---

<div class="post-metadata">

**Author:** ![randy\_k](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/258eb7/32.png) [@randy\_k](https://www.ruby-forum.com/u/randy_k)\
**Post date:** [March 24, 2006, 4:05pm UTC](https://www.ruby-forum.com/t/directory-structure-of-a-ruby-installation-including-the-pa/55791/3 "2006-03-24T16:05:11Z")

</div>

On Thursday 23 March 2006 04:03 pm, Ross B. wrote:

> On Fri, 2006-03-24 at 05:31 +0900, Randy K. wrote:
> 
> > For a variety of reasons, I’m trying to get a better understanding of how  
> > a Ruby installation is laid out on disk. Maybe the best way to explain  
> > what I mean is by giving some of the specific questions I have. (Maybe  
> > these are not so much Ruby specific, but maybe generic to a typical  
> > language install.)

——

> Hope that helps,

Yes, very much, thanks! (It may take me a little while to “internalize”  
everything, but most of it is pretty clear and close to what I  
expected.)

After sending the original email, I began to wonder about the location  
of the  
ri/rdoc documentation (that is, for example, the stuff generated by the  
=make  
install-doc= step), i.e., being concerned that it might be in the  
“install  
directory”, and thus, a reason not to delete that directory (not that  
I’m all  
that worried or intent on deleting that directory, it’s just part of  
understanding where things have to be.

Anyway, I found that in /usr/local/share/ri/1.8, so again, no worries  
about  
deleting the tarball/install directory.

I do have more questions, they’re focused on getting the TkHTML widget  
to  
work–but I’ll try to get my head screwed on straight and then ask those  
in a  
new thread.

Thanks again!  
Randy K.
