Directory structure of a Ruby installation, including the paths that should be set, etc.

R

Randy Kramer

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 Kramer
 
R

Ross Bamford

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

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,730
Latest member
AudryNolan

Latest Threads

Top