From: Brian Candler Date: 2011-10-07T18:11:54+09:00 Subject: Re: don't understand -r Thomas Sawyer wrote in post #1025489: > Can anyone explain to me why, with RUBYOPT="-rubgems" The difference is not whether you provide -rubygems on the command line or in an environment variable. The difference is whether you use -ransi or -e'require "ansi"' Note that none of these work: $ ruby -rbundler -e 'puts "hello"' ruby: no such file to load -- bundler (LoadError) $ ruby -rubygems -rbundler -e 'puts "hello"' ruby: no such file to load -- bundler (LoadError) $ env RUBYOPT="-rubygems" ruby -rbundler -e 'puts "hello"' ruby: no such file to load -- bundler (LoadError) But it works this way if you have -rubygems: $ ruby -e 'require "bundler"; puts "hello"' -e:1:in `require': no such file to load -- bundler (LoadError) from -e:1 $ ruby -rubygems -e 'require "bundler"; puts "hello"' hello $ env RUBYOPT="-rubygems" ruby -e 'require "bundler"; puts "hello"'hello hello This is with ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux] I imagine it's because rubygems redefines Kernel#require, but using -r on the command line calls the internal require function directly. If -r doesn't do a full method dispatch, then rubygems can't override what it does. -- Posted via http://www.ruby-forum.com/.