зеркало из https://github.com/github/ruby.git
[rubygems/rubygems] Include original error when openssl fails to load
https://github.com/rubygems/rubygems/commit/440343b791
This commit is contained in:
Родитель
38b07a7fee
Коммит
ae733a693b
|
@ -37,8 +37,9 @@ module Bundler
|
|||
# This is the error raised when a source is HTTPS and OpenSSL didn't load
|
||||
class SSLError < HTTPError
|
||||
def initialize(msg = nil)
|
||||
super msg || "Could not load OpenSSL.\n" \
|
||||
"You must recompile Ruby with OpenSSL support."
|
||||
super "Could not load OpenSSL.\n" \
|
||||
"You must recompile Ruby with OpenSSL support.\n" \
|
||||
"original error: #{msg}\n"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -251,7 +252,13 @@ module Bundler
|
|||
needs_ssl = remote_uri.scheme == "https" ||
|
||||
Bundler.settings[:ssl_verify_mode] ||
|
||||
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
|
||||
if gem_proxy = Gem.configuration[:http_proxy]
|
||||
|
|
|
@ -738,14 +738,14 @@ RSpec.describe "compact index api" do
|
|||
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
|
||||
source "#{source_uri.gsub(/http/, "https")}"
|
||||
gem "myrack"
|
||||
G
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -707,14 +707,14 @@ RSpec.describe "gemcutter's dependency API" do
|
|||
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
|
||||
source "#{source_uri.gsub(/http/, "https")}"
|
||||
gem "myrack"
|
||||
G
|
||||
|
||||
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
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче