[前][次][番号順一覧][スレッド一覧]

ruby-changes:68433

From: David <ko1@a...>
Date: Wed, 13 Oct 2021 23:30:31 +0900 (JST)
Subject: [ruby-changes:68433] 30b6df4144 (master): [rubygems/rubygems] Improve error messages in gem helpers

https://git.ruby-lang.org/ruby.git/commit/?id=30b6df4144

From 30b6df41440ea2a0421efd0f3146750e872760fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 25 Aug 2021 11:30:41 +0200
Subject: [rubygems/rubygems] Improve error messages in gem helpers

Previously they were printing the original command that was run, and
telling the user to rerun it. However, the command sometimes would not
match the exact command that was run (for example, when using the
`--local` flag), and in any case, it's simpler and more useful to print
the underlying error anyways.

https://github.com/rubygems/rubygems/commit/5bc0d51b58
---
 lib/bundler/gem_helper.rb               | 6 +++---
 spec/bundler/bundler/gem_helper_spec.rb | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index 8e1dd7c4f2..01101205e3 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -98,9 +98,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/gem_helper.rb#L98
       built_gem_path ||= build_gem
       cmd = [*gem_command, "install", built_gem_path.to_s]
       cmd << "--local" if local
-      _, status = sh_with_status(cmd)
+      out, status = sh_with_status(cmd)
       unless status.success?
-        raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output"
+        raise("Running `#{cmd}` failed with the following output:\n\n#{out}\n")
       end
       Bundler.ui.confirm "#{name} (#{version}) installed."
     end
@@ -219,7 +219,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/gem_helper.rb#L219
       out, status = sh_with_status(cmd, &block)
       unless status.success?
         cmd = cmd.shelljoin if cmd.respond_to?(:shelljoin)
-        raise(out.empty? ? "Running `#{cmd}` failed. Run this command directly for more detailed output." : out)
+        raise("Running `#{cmd}` failed with the following output:\n\n#{out}\n")
       end
       out
     end
diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb
index 6c3ac3e035..2c43719aa1 100644
--- a/spec/bundler/bundler/gem_helper_spec.rb
+++ b/spec/bundler/bundler/gem_helper_spec.rb
@@ -219,7 +219,7 @@ RSpec.describe Bundler::GemHelper do https://github.com/ruby/ruby/blob/trunk/spec/bundler/bundler/gem_helper_spec.rb#L219
             FileUtils.touch app_gem_path
             app_gem_path
           end
-          expect { subject.install_gem }.to raise_error(/Couldn't install gem/)
+          expect { subject.install_gem }.to raise_error(/Running `#{gem_bin} install #{app_gem_path}` failed/)
         end
       end
     end
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]