[rubygems/rubygems] Include original error when openssl fails to load
https://github.com/rubygems/rubygems/commit/440343b791
This commit is contained in:
parent
38b07a7fee
commit
ae733a693b
@ -37,8 +37,9 @@ module Bundler
|
|||||||
# This is the error raised when a source is HTTPS and OpenSSL didn't load
|
# This is the error raised when a source is HTTPS and OpenSSL didn't load
|
||||||
class SSLError < HTTPError
|
class SSLError < HTTPError
|
||||||
def initialize(msg = nil)
|
def initialize(msg = nil)
|
||||||
super msg || "Could not load OpenSSL.\n" \
|
super "Could not load OpenSSL.\n" \
|
||||||
"You must recompile Ruby with OpenSSL support."
|
"You must recompile Ruby with OpenSSL support.\n" \
|
||||||
|
"original error: #{msg}\n"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -251,7 +252,13 @@ module Bundler
|
|||||||
needs_ssl = remote_uri.scheme == "https" ||
|
needs_ssl = remote_uri.scheme == "https" ||
|
||||||
Bundler.settings[:ssl_verify_mode] ||
|
Bundler.settings[:ssl_verify_mode] ||
|
||||||
Bundler.settings[:ssl_client_cert]
|
Bundler.settings[:ssl_client_cert]
|
||||||
raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
|
if needs_ssl
|
||||||
|
begin
|
||||||
|
require "openssl"
|
||||||
|
rescue StandardError, LoadError => e
|
||||||
|
raise SSLError.new(e.message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
con = Gem::Net::HTTP::Persistent.new name: "bundler", proxy: :ENV
|
con = Gem::Net::HTTP::Persistent.new name: "bundler", proxy: :ENV
|
||||||
if gem_proxy = Gem.configuration[:http_proxy]
|
if gem_proxy = Gem.configuration[:http_proxy]
|
||||||
|
@ -738,14 +738,14 @@ RSpec.describe "compact index api" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "explains what to do to get it" do
|
it "explains what to do to get it, and includes original error" do
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{source_uri.gsub(/http/, "https")}"
|
source "#{source_uri.gsub(/http/, "https")}"
|
||||||
gem "myrack"
|
gem "myrack"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle :install, env: { "RUBYOPT" => opt_add("-I#{bundled_app("broken_ssl")}", ENV["RUBYOPT"]) }, raise_on_error: false, artifice: nil
|
bundle :install, env: { "RUBYOPT" => opt_add("-I#{bundled_app("broken_ssl")}", ENV["RUBYOPT"]) }, raise_on_error: false, artifice: nil
|
||||||
expect(err).to include("OpenSSL")
|
expect(err).to include("recompile Ruby").and include("cannot load such file")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -707,14 +707,14 @@ RSpec.describe "gemcutter's dependency API" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "explains what to do to get it" do
|
it "explains what to do to get it, and includes original error" do
|
||||||
gemfile <<-G
|
gemfile <<-G
|
||||||
source "#{source_uri.gsub(/http/, "https")}"
|
source "#{source_uri.gsub(/http/, "https")}"
|
||||||
gem "myrack"
|
gem "myrack"
|
||||||
G
|
G
|
||||||
|
|
||||||
bundle :install, artifice: "fail", env: { "RUBYOPT" => opt_add("-I#{bundled_app("broken_ssl")}", ENV["RUBYOPT"]) }, raise_on_error: false
|
bundle :install, artifice: "fail", env: { "RUBYOPT" => opt_add("-I#{bundled_app("broken_ssl")}", ENV["RUBYOPT"]) }, raise_on_error: false
|
||||||
expect(err).to include("OpenSSL")
|
expect(err).to include("recompile Ruby").and include("cannot load such file")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user