This fixes #2369
The main symptom that led me to encounter it was that I was unable to perform a gem install to the system location within a bundle exec'd process (chef, in this case) - PATH and friends were being bashed over because ORIGINAL_ENV was being read from within the subprocess and not passed through.
I'm unsure whether I should be preserving the _ORIGINAL_GEM_PATH env var for compatibility in this.
Also, f15cf14 is independent of this feature (the example group was pointless in its previous form), if you want to cherry pick separately
Test the right method w/ the 'Bundler.with_*_env' shared example group
Failing specs for with_original_env
Preserve the full environment for with_original_env
Don't depend on json to support 1.8
This seems right to me, but I'm worried about exporting and importing marshalled data :\ I'm not sure if there's a better solution, though.
I could go with a custom format, but that seems more fragile - I wish I could depend on json ><
Is marshal stable between versions/engines? Is it possible to switch interpreters between calls here?
On further thought. Marshal is a really bad idea. This wold be a nice vector for code injection!
I still think this is a worthwhile goal (although very few people have multiple levels of exec, afaict). The only way I can think of for this to be doable before Bundler 2.0 (where we'll drop 1.8 and be able to use json) is to reuse the ghetto YAML parser in Bundler::Settings. We can't use a real YAML parser in the runtime because that breaks Psych :(