From: Thomas Sawyer Date: 2011-10-14T00:47:10+09:00 Subject: [ruby-core:40139] [Ruby 1.9 - Bug #5445][Open] Need RUBYOPT -r before ARGV -r Issue #5445 has been reported by Thomas Sawyer. ---------------------------------------- Bug #5445: Need RUBYOPT -r before ARGV -r http://redmine.ruby-lang.org/issues/5445 Author: Thomas Sawyer Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3dev (2011-07-03 trunk 32372) [x86_64-linux] Libraries given by -r options in RUBYOPT should be loaded before ones in direct command line arguments. I use a custom load system for development that I have been using for years and it works very well for me. But Ruby has some edge cases that prevents it from being feature complete. One of these is the order in which RUBYOPT is applied vs. -r command line option. My custom loader is too large to include here, so I will simply demonstrate the problem with simple sample code: $ cat req.rb p "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 If we load this via RUBYOPT, the result is: $ RUBYOPT=-r./req.rb ruby -rstringio -e0 Custom Require But if we load via -r the result is: $ ruby -r./req.rb -rstringio -e0 Custom Require Kernel#require ["stringio"] I would ask that the output of both invocations to be identical. (Note, the -T option should still allow RUBYOPT to be omitted regardless.) -- http://redmine.ruby-lang.org