diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2017-02-01 14:52:08 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2017-02-14 20:35:47 +0900 |
commit | a78583c9c472d3e6b1b7e4c3e8e510141b6bab10 (patch) | |
tree | abc4d9d4de89a318f6985b8985a6c950f3f34d84 | |
parent | 8c0cbf3c03a56b8cdfeaba2558c35f461608b287 (diff) | |
download | bundler-a78583c9c472d3e6b1b7e4c3e8e510141b6bab10.tar.gz |
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: https://github.com/bundler/bundler/issues/5235
Fixes: https://github.com/ruby/openssl/issues/103
-rw-r--r-- | lib/bundler/lazy_specification.rb | 1 | ||||
-rw-r--r-- | lib/bundler/remote_specification.rb | 1 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 1 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 1 | ||||
-rw-r--r-- | spec/runtime/setup_spec.rb | 15 |
5 files changed, 14 insertions, 5 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 7508347c32..ed21a9aad4 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "uri" -require "rubygems/spec_fetcher" require "bundler/match_platform" module Bundler diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index 112c7f97fe..944ff1adbd 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true require "uri" -require "rubygems/spec_fetcher" module Bundler # Represents a lazily loaded gem specification, where the full specification diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index dfe41ec783..90768aac1d 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -213,6 +213,7 @@ module Bundler end def fetch_specs(all, pre, &blk) + require "rubygems/spec_fetcher" specs = Gem::SpecFetcher.new.list(all, pre) specs.each { yield } if block_given? specs diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 1ff2f6c6ed..a56170be17 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "uri" require "rubygems/user_interaction" -require "rubygems/spec_fetcher" module Bundler class Source diff --git a/spec/runtime/setup_spec.rb b/spec/runtime/setup_spec.rb index 09e88630ca..f5b74833be 100644 --- a/spec/runtime/setup_spec.rb +++ b/spec/runtime/setup_spec.rb @@ -1080,8 +1080,8 @@ RSpec.describe "Bundler.setup" do end end - describe "when Psych is not in the Gemfile", :ruby => "~> 2.2" do - it "does not load Psych" do + describe "with gemified standard libraries" do + it "does not load Psych", :ruby => "~> 2.2" do gemfile "" ruby <<-RUBY require 'bundler/setup' @@ -1093,6 +1093,17 @@ RSpec.describe "Bundler.setup" do expect(pre_bundler).to eq("undefined") expect(post_bundler).to match(/\d+\.\d+\.\d+/) end + + it "does not load openssl" do + install_gemfile! "" + ruby! <<-RUBY + require "bundler/setup" + puts defined?(OpenSSL) || "undefined" + require "openssl" + puts defined?(OpenSSL) || "undefined" + RUBY + expect(out).to eq("undefined\nconstant") + end end describe "after setup" do |