diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2021-07-31 14:10:59 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2021-08-31 19:06:14 +0900 |
commit | 0b4dbe2e6a0a0b27860fb6a509ff0429ece436c7 (patch) | |
tree | 5aa8e35b7ffe852ee7b16f97cfaab9872b71e925 /lib/bundler/source | |
parent | 2e850e0038e8ba9a5dd3266e9f0f6b2821f19084 (diff) |
[rubygems/rubygems] Improve "gem not found in source" errors
When printing sources inside these error messages, it's useful to only
consider the current state of the source. For example, when requiring
`bundler/setup`, the source shouldn't be configured to be able to hit
the network, so the error message should only mention "locally installed
gems" to make that more clear.
https://github.com/rubygems/rubygems/commit/30eb14f853
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4789
Diffstat (limited to 'lib/bundler/source')
-rw-r--r-- | lib/bundler/source/rubygems.rb | 17 | ||||
-rw-r--r-- | lib/bundler/source/rubygems_aggregate.rb | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index 858a69a48b..6728ffdc63 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -96,11 +96,22 @@ module Bundler out << " specs:\n" end + def to_err + if remotes.empty? + "locally installed gems" + elsif @allow_remote + "rubygems repository #{remote_names} or installed locally" + elsif @allow_cached + "cached gems from rubygems repository #{remote_names} or installed locally" + else + "locally installed gems" + end + end + def to_s if remotes.empty? "locally installed gems" else - remote_names = remotes.map(&:to_s).join(", ") "rubygems repository #{remote_names} or installed locally" end end @@ -319,6 +330,10 @@ module Bundler protected + def remote_names + remotes.map(&:to_s).join(", ") + end + def credless_remotes remotes.map(&method(:suppress_configured_credentials)) end diff --git a/lib/bundler/source/rubygems_aggregate.rb b/lib/bundler/source/rubygems_aggregate.rb index 685bf7e90a..09cf4002ea 100644 --- a/lib/bundler/source/rubygems_aggregate.rb +++ b/lib/bundler/source/rubygems_aggregate.rb @@ -16,6 +16,10 @@ module Bundler @index end + def to_err + to_s + end + def to_s "any of the sources" end |