From: Intransition Date: 2011-10-08T23:22:49+09:00 Subject: Re: don't understand -r On Oct 8, 5:24 am, Brian Candler wrote: > Thomas Sawyer wrote in post #1025570: > > > btw, my original usecase, that led me this, was an attempt to run > > minitest-based tests through a custom report format. > > >     $ ruby -r'minitest/tapy' test/test-*.rb > > And the problem is that this doesn't work because rubygems isn't > installed, or something else? > > 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.