From 0005967c7a573acdd63affa68e02e8072e7ed825 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Mon, 30 Dec 2019 22:07:45 -0500 Subject: Report original exception when failing to load openssl, fixes #7192 --- lib/bundler/friendly_errors.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index 080697b02c..8c22b54972 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -23,7 +23,7 @@ module Bundler Bundler.ui.error error.message when LoadError raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/ - Bundler.ui.error "\nCould not load OpenSSL." + Bundler.ui.error "\nCould not load OpenSSL: #{error.class}: #{error}" Bundler.ui.warn <<-WARN, :wrap => true You must recompile Ruby with OpenSSL support or change the sources in your \ Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \ -- cgit v1.2.1 From 5bd34aacd134d3f41be0247d8eb1b8bd00e8a26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 3 Jan 2020 12:14:05 +0100 Subject: Tweak --- lib/bundler/friendly_errors.rb | 2 +- spec/bundler/friendly_errors_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index 8c22b54972..4664088084 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -23,7 +23,7 @@ module Bundler Bundler.ui.error error.message when LoadError raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/ - Bundler.ui.error "\nCould not load OpenSSL: #{error.class}: #{error}" + Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}" Bundler.ui.warn <<-WARN, :wrap => true You must recompile Ruby with OpenSSL support or change the sources in your \ Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \ diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index e9189b0514..e89fa01f45 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -116,7 +116,7 @@ RSpec.describe Bundler, "friendly errors" do let(:error) { LoadError.new("cannot load such file -- openssl") } it "Bundler.ui receive error" do - expect(Bundler.ui).to receive(:error).with("\nCould not load OpenSSL.") + expect(Bundler.ui).to receive(:error).with("\nCould not load OpenSSL. LoadError: cannot load such file -- openssl") Bundler::FriendlyErrors.log_error(error) end -- cgit v1.2.1 From 0fb17fce4068f6f82bcbfca0515e0a40401c3143 Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Wed, 22 Jan 2020 15:07:39 -0500 Subject: remove trace and update the specs accordingly --- lib/bundler/friendly_errors.rb | 1 - spec/bundler/friendly_errors_spec.rb | 5 ----- 2 files changed, 6 deletions(-) diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index 4664088084..9d8b67f55a 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -29,7 +29,6 @@ module Bundler Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \ using RVM are available at https://rvm.io/packages/openssl. WARN - Bundler.ui.trace error when Interrupt Bundler.ui.error "\nQuitting..." Bundler.ui.trace error diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index e89fa01f45..db27622b79 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -124,11 +124,6 @@ RSpec.describe Bundler, "friendly errors" do expect(Bundler.ui).to receive(:warn).with(any_args, :wrap => true) Bundler::FriendlyErrors.log_error(error) end - - it "Bundler.ui receive trace" do - expect(Bundler.ui).to receive(:trace).with(error) - Bundler::FriendlyErrors.log_error(error) - end end context "Interrupt" do -- cgit v1.2.1 From 7aa323a8396782b351e95bfa3f3456bd2db3c682 Mon Sep 17 00:00:00 2001 From: Emily Giurleo Date: Wed, 22 Jan 2020 15:29:31 -0500 Subject: always print backtrace on LoadError --- lib/bundler/friendly_errors.rb | 2 +- spec/bundler/friendly_errors_spec.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index 9d8b67f55a..046a666003 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -23,7 +23,7 @@ module Bundler Bundler.ui.error error.message when LoadError raise error unless error.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/ - Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}" + Bundler.ui.error "\nCould not load OpenSSL. #{error.class}: #{error}\n#{error.backtrace.join("\n ")}" Bundler.ui.warn <<-WARN, :wrap => true You must recompile Ruby with OpenSSL support or change the sources in your \ Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \ diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index db27622b79..125724d3ea 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -115,8 +115,12 @@ RSpec.describe Bundler, "friendly errors" do context "LoadError" do let(:error) { LoadError.new("cannot load such file -- openssl") } + before do + allow(error).to receive(:backtrace).and_return(["backtrace"]) + end + it "Bundler.ui receive error" do - expect(Bundler.ui).to receive(:error).with("\nCould not load OpenSSL. LoadError: cannot load such file -- openssl") + expect(Bundler.ui).to receive(:error).with("\nCould not load OpenSSL. LoadError: cannot load such file -- openssl\nbacktrace") Bundler::FriendlyErrors.log_error(error) end -- cgit v1.2.1