On Oct 8, 5:24am, Brian C. [email protected] wrote:
For me, -r works with rubygems in 1.9.2:
$ sudo gem192 install haml
Successfully installed haml-3.1.3
…
$ ruby192 -rhaml -e ‘p Haml.constants’
[:ROOT_DIR, :Util, :Version, :VERSION, :Helpers, :Buffer, :Shared,
:Parser, :Compiler, :Filters, :Error, :SyntaxError, :Engine]
$ ruby192 -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
Yes, I have been informed that with 1.9.x, rubygems is always loaded
so RUBYOPT=“-rubygems” is no longer even needed. That fixes the issue
for loading from gems. It remains however a limitation for any custom
load manager, like the one I use.
A simpler example of the limitation would be load monitor --overriding
require to log everything request.
$ cat req.rb
puts “Custom Require”
module Kernel
alias :require0 :require
def require(*a)
puts "Kernel#require"
p a
require0(*a)
end
class << self
alias :require0 :require
def require(*a)
puts "Kernel.require"
p a
require0(*a)
end
end
end
Now if we do:
$ export RUBYOPT=“-rreq.rb”
Then the difference between:
ruby -rhaml -e’p Haml.constants’
and
ruby -e’require “haml”; p Haml.constants’
is apparent.