@@ -48,7 +48,14 @@ def run(ruby:, ruby_description:)
4848
4949 result_json_path = caller_json_path || File . join ( out_path , "temp#{ Process . pid } .json" )
5050 cmd_prefix = base_cmd ( ruby_description , entry . name )
51- result = run_single_benchmark ( entry . script_path , result_json_path , ruby , cmd_prefix , env , entry . name )
51+
52+ result = if defined? ( Bundler )
53+ Bundler . with_unbundled_env do
54+ run_single_benchmark ( entry . script_path , result_json_path , ruby , cmd_prefix , env , entry . name )
55+ end
56+ else
57+ run_single_benchmark ( entry . script_path , result_json_path , ruby , cmd_prefix , env , entry . name )
58+ end
5259
5360 if result [ :success ]
5461 bench_data [ entry . name ] = process_benchmark_result ( result_json_path , result [ :command ] , delete_file : !caller_json_path )
@@ -177,15 +184,6 @@ def benchmark_env(ruby)
177184 end
178185 end
179186
180- # Clear Bundler environment variables to prevent the parent's bundle context
181- # from leaking into benchmark subprocesses. Benchmarks that need Bundler will
182- # set up their own context via use_gemfile in the harness.
183- # This is especially important when running tests under `bundle exec rake test`.
184- [ "BUNDLE_GEMFILE" , "BUNDLE_BIN_PATH" , "BUNDLE_PATH" , "BUNDLER_VERSION" ,
185- "BUNDLER_SETUP" , "RUBYOPT" , "RUBYLIB" ] . each do |var |
186- env [ var ] = nil if ENV . key? ( var )
187- end
188-
189187 env
190188 end
191189
0 commit comments