From: Eric Hodel Date: 2011-10-08T15:16:55+09:00 Subject: [ruby-core:40045] [Ruby 1.9 - Feature #5421] -r option useless Issue #5421 has been updated by Eric Hodel. =begin req.rb doesn't seem to match your description: $ ruby -rmyplugin script.rb It tells me "no such file" for myplugin. Where is myplugin.rb? If it is in a gem this should work fine as I've shown above. If it's in the current directory maybe you need to add "." to the load path, it is no longer present in ruby 1.9. Turns out the problem is that the -r option uses internal require code and thus circumvents rubygems or any modified #require, This is no longer true as I've demonstrated above. require is modified in lib/rubygems/custom_require.rb. Loading your script directly works fine too: $ ruby19 -r./req -rstringio -e0 "Custom Require" Kernel#require ["stringio"] $ so even though my RUBYOPT="-rubygems", it makes no difference. There's no need to RUBYOPT="-rubygems" anymore. RubyGems is present by default. I've also been informed that RUBYOPT is applied after -r options, which makes for an additional problem. Apparently this so -T can ignore RUBYOPT? But if that's the only reason, then -T should be preparsed from ARGV b/c having -r options load first prevents augmentation and use of what RUBYOPT loads by -r. RUBYOPT is supposed to set the environment, but it isn't much of an environment if its not there when I run a ruby command. The discussion on when options from RUBYOPT is parsed appears not to be part of your problem. =end ---------------------------------------- Feature #5421: -r option useless http://redmine.ruby-lang.org/issues/5421 Author: Thomas Sawyer Status: Rejected Priority: Normal Assignee: Category: core Target version: Ran into a problem trying to require a plugin I had written while running a ruby scipt, e.g. $ ruby -rmyplugin script.rb It tells me "no such file" for myplugin. Turns out the problem is that the -r option uses internal require code and thus circumvents rubygems or any modified #require, so even though my RUBYOPT="-rubygems", it makes no difference. I've also been informed that RUBYOPT is applied after -r options, which makes for an additional problem. Apparently this so -T can ignore RUBYOPT? But if that's the only reason, then -T should be preparsed from ARGV b/c having -r options load first prevents augmentation and use of what RUBYOPT loads by -r. RUBYOPT is supposed to set the environment, but it isn't much of an environment if its not there when I run a ruby command. I've marked this report as a feature b/c I'm sure someone would take issue if I did otherwise, but I personally see it as a bug b/c it makes -r useless in many cases. -- http://redmine.ruby-lang.org