From: "mame (Yusuke Endoh)" Date: 2012-03-27T22:38:24+09:00 Subject: [ruby-core:43731] [ruby-trunk - Feature #5445][Assigned] Need RUBYOPT -r before ARGV -r Issue #5445 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to matz (Yukihiro Matsumoto) ---------------------------------------- Feature #5445: Need RUBYOPT -r before ARGV -r https://bugs.ruby-lang.org/issues/5445#change-25237 Author: trans (Thomas Sawyer) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: 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://bugs.ruby-lang.org/