On 6/29/06, Lanny R. [email protected] wrote:
Thanks. Setting RUBYOPTS would not be a hack if it worked. In my case ir
would be /usr/local/lib/ruby/site_ruby/but that is precicely where the
GEMS do not get installed by gem install …
What the RUBYOPT environment variable provides is a default set of
flags to provide to the ruby runtime. So these are essentially
RUBYOPT=-rubygems ruby foo.rb
ruby -rubygems foo.rb
An added bonus to using RUBYOPT is that scripts marked as executable
and with a shebang will receive the benefit as well. So if you’re
script starts with #!/usr/bin/ruby, then setting RUBYOPT=-rubygems
before running the script is the same as changing the shebang to
include the -rubygems flag.
Now, the -rubygems flag itself isn’t really it’s own flag, it’s a
clever use of Ruby’s -r flag. The -r flag requires its argument at the
start of the script, as if you had added a require statement. So using
the -rubygems flag (or placing -rubygems in your RUBYOPT) is
equivalent to adding the following line to the top of every script:
The ubygems.rb file (in /usr/lib/ruby/site_ruby/1.8/ on my system) in
turn simply loads the actual ‘rubygems’ library. The ‘ubygems’ version
is there just so you can type a -rubygems flag rather than -rrubygems.
So… setting RUBYOPT=-rubygems is essentially equivalent to adding
require ‘rubygems’ to each of your scripts, all through one
Thank you for your help. I am not about to grep through all files
prepending a missing line of code, that is no fun :-). I’ll wait for a
while to see if this is fixed and play with Ruby on my Mac where it
works perfectly - same version, same gems and same typi application.
My guess is that it works on your Mac but not on your other machine
because the Mac already has the RUBYOPT environment variable set up,
while your other machine doesn’t. You can check with:
on both machines at the command line. You can also try:
in your typo directory.