This is for an executable packaged in a gem, i.e.,
I have no control over the user's RUBYOPT variable?
(Note: the gem is also available as a tarball,
hence the initial attempt w/o rubygems.)
If that's the case, don't bother doing anything special. Just require
your own code. Let's say you've got foo-1.0 with bin/foo that requires
lib/foo/foo.rb.
If installed as a tarball, bin/foo is installed into your standard bin
directory and it will just require 'foo/foo' as normal, because
lib/foo/foo.rb will be in SITE_RUBY.
if installed as a gem, bin/foo is installed into the gem's directory,
and an executable stub is installed into the standard bin directory.
The executable stub will do something like "gem 'foo'", and then load
"$(PATH_TO_FOO_GEM)/bin/foo".
Either way, you'll get the right behaviour.
-austin