Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit c7f3d05

Browse files
committed
Auto merge of #5388 - rhenium:topic/defer-requiring-rubygems-spec_fetcher, r=segiddins
Defer requiring rubygems/spec_fetcher until it becomes necessary Avoid conflict between two versions of openssl gem on 'bundle exec' if a newer and non-default version of openssl gem is installed to the system. rubygems/spec_fetcher loads openssl through resolv and securerandom when running with Ruby <= 2.4. This is not a proper fix for #5235 as other standard libraries that Bundler currently loads will be gemified as well in Ruby >= 2.5, however, this will fix openssl's case. Reference: #5235 Fixes: ruby/openssl#103 --- Reproduce: 1. Install Ruby 2.4.0 (comes with openssl 2.0.2) 2. Run `gem install openssl` to install openssl 2.0.3 3. Create a Gemfile and run `bundle install` 4. Run `bundle exec ruby -e'require "openssl"'
2 parents 42b1e1b + a78583c commit c7f3d05

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

lib/bundler/lazy_specification.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22
require "uri"
3-
require "rubygems/spec_fetcher"
43
require "bundler/match_platform"
54

65
module Bundler

lib/bundler/remote_specification.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22
require "uri"
3-
require "rubygems/spec_fetcher"
43

54
module Bundler
65
# Represents a lazily loaded gem specification, where the full specification

lib/bundler/rubygems_integration.rb

+1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def ext_lock
213213
end
214214

215215
def fetch_specs(all, pre, &blk)
216+
require "rubygems/spec_fetcher"
216217
specs = Gem::SpecFetcher.new.list(all, pre)
217218
specs.each { yield } if block_given?
218219
specs

lib/bundler/source/rubygems.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22
require "uri"
33
require "rubygems/user_interaction"
4-
require "rubygems/spec_fetcher"
54

65
module Bundler
76
class Source

spec/runtime/setup_spec.rb

+13-2
Original file line numberDiff line numberDiff line change
@@ -1080,8 +1080,8 @@ def lock_with(ruby_version = nil)
10801080
end
10811081
end
10821082

1083-
describe "when Psych is not in the Gemfile", :ruby => "~> 2.2" do
1084-
it "does not load Psych" do
1083+
describe "with gemified standard libraries" do
1084+
it "does not load Psych", :ruby => "~> 2.2" do
10851085
gemfile ""
10861086
ruby <<-RUBY
10871087
require 'bundler/setup'
@@ -1093,6 +1093,17 @@ def lock_with(ruby_version = nil)
10931093
expect(pre_bundler).to eq("undefined")
10941094
expect(post_bundler).to match(/\d+\.\d+\.\d+/)
10951095
end
1096+
1097+
it "does not load openssl" do
1098+
install_gemfile! ""
1099+
ruby! <<-RUBY
1100+
require "bundler/setup"
1101+
puts defined?(OpenSSL) || "undefined"
1102+
require "openssl"
1103+
puts defined?(OpenSSL) || "undefined"
1104+
RUBY
1105+
expect(out).to eq("undefined\nconstant")
1106+
end
10961107
end
10971108

10981109
describe "after setup" do

0 commit comments

Comments
 (0)