Directory structure of a Ruby installation, including the pa


#1

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.

    • Was that an appropriate place to untar? Does it matter much, or
      at
      all? (I mean, as long as I have the necessary permissions to untar and
      access the files.)
  • 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.


#2

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,


#3

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.