I ran into this issue this week, and found the bug report at
http://github.com/carlhuda/bundler/issues/issue/478/ (and commented
there).
I appreciate that supporting changes that affect launched ruby
processes is no easy task, and that either way you go you will have to
deal with people complaining. Choosing the solution that gets fewer
complaints is easier, but wrong.
A very simple reason why it's wrong is that, without knowledge of
bundler, currently this issue cannot be worked around for libraries
that launch other ruby processes. That is, a library has to remove
bundler's meddling from RUBYOPT, and know to look for the "-r bundler/
setup" to remove it (or, detect if a method Bundler.with_clean_env
exists and use that). This is extremely undesirable, and expecting any/
every library which wishes to launch a clean ruby process to be aware
that bundler may have meddled, is not reasonable.
Even if it is considered acceptable that every other ruby-launching
library should work with or around Bundler, that assumes that bundler
is unique. If this is deemed acceptable behavior, then every library
will have to do the same thing for any other thing that may decide to
add itself into RUBYOPT. It's out of hand already with bundler doing
this; it's a complete nightmare when some other library (say a new
competitor to bundler, or whatever) starts doing it (repeat N times).
On the other hand, the main problem with not setting up bundler in
spawned ruby instances, by my understanding (I may be wrong; I'm sure
I will be corrected if so), is the $LOAD_PATH. A spawned ruby won't
know to look in bundler's paths. However, it is perfectly possible for
libraries to launch other ruby processes with the changes that bundler
makes without any knowledge of bundler itself, by invoking ruby with -
I flags corresponding to its own current $LOAD_PATH. Plenty of things
change the $LOAD_PATH (bundler, rubygems, other gems, etc) and things
that launch other ruby processes must be aware that they're going to
need to tell the spawned ruby where to look for things.
Rubygems has managed to get by without inserting itself into RUBYOPT.
Replicating the load path for spawned ruby processes so that they can
find gems must be a more common problem for rubygems than for bundler
(I have dealt with this issue myself with rubygems). If rubygems
(being much more prevalent) doesn't need to do this, I don't think
there is good reason (or sufficient reason, anyway) for bundler to do
so.
Please reconsider removing this awful behavior from bundler.
-Ethan