Subject: Re: Installation query
Date: Wed 16 Jan 13 04:01:42AM +0900
Quoting Ron H. ([email protected]):
This is perhaps not totally resolved. Though ruby -v says 1.9, I’m not
sure that’s what’s actually running. I was expecting that the scope of a
local variable would not override that of a block variable, but it has,
which I understand changed with 1.9. Is there some way I can know which
version is actually running?
Yup. There is a global constant calld RUBY_VERSION. If you write a
program that reads
puts RUBY_VERSION
and save it as ‘prog.rb’, for example, then you can do
ruby prog.rb
and read the output.
Also, when i look in the Library/Ruby directory, there is only a 1.8
folder . . .?
In Linux, ruby stuff is held in /usr/lib/ruby (or /usr/local/lib/ruby
if you compile ruby by yourself). Probably this is true also with mac?
Have a look…
There is another teeny little pretty unix utility called strace. It
may also be included in macos - I don’t know. One way you can run it
is as
strace -eopen ruby prog.rb
It will print out all files it tries, more or less successfully, to
open. This way you can see in practice where your libraries are being
fetched. For example, in my system a system .rb file is searched for
in 7 places before it is eventually found:
open("/usr/local/lib/ruby/site_ruby/2.0.0/rbconfig.rb",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/ruby/site_ruby/2.0.0/x86_64-linux/rbconfig.rb",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/ruby/site_ruby/rbconfig.rb", O_RDONLY|O_CLOEXEC) =
-1 ENOENT (No such file or directory)
open("/usr/local/lib/ruby/vendor_ruby/2.0.0/rbconfig.rb",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/ruby/vendor_ruby/2.0.0/x86_64-linux/rbconfig.rb",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/ruby/vendor_ruby/rbconfig.rb", O_RDONLY|O_CLOEXEC)
= -1 ENOENT (No such file or directory)
open("/usr/local/lib/ruby/2.0.0/rbconfig.rb", O_RDONLY|O_CLOEXEC) = -1
ENOENT (No such file or directory)
open("/usr/local/lib/ruby/2.0.0/x86_64-linux/rbconfig.rb",
O_RDONLY|O_CLOEXEC) = 5
(btw, rbconfig.rb is the file where RUBY_VERSION is defined)
Carlo