summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2025-09-01 20:27:30 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2025-09-03 23:38:37 +0900
commitcc2a70da2781d10016746e5fd03de9cc2f7b5ceb (patch)
tree2ac82e20ccc42fa4bc51e80fa3e844195ff237d2 /lib
parentcdb8c9e254d1e0b8de036bc2709915d146af0271 (diff)
[rubygems/rubygems] Warn when trying to remove a default source that's the only configured sources
https://github.com/rubygems/rubygems/commit/ef78de5b69
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/commands/sources_command.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/rubygems/commands/sources_command.rb b/lib/rubygems/commands/sources_command.rb
index c878333b14..9e2f156da3 100644
--- a/lib/rubygems/commands/sources_command.rb
+++ b/lib/rubygems/commands/sources_command.rb
@@ -208,7 +208,11 @@ To remove a source use the --remove argument:
Gem.sources.delete source
Gem.configuration.write
- say "#{source_uri} removed from sources"
+ if default_sources.include?(source) && configured_sources.one?
+ alert_warning "Removing a default source when it is the only source has no effect. Add a different source to #{config_file_name} if you want to stop using it as a source."
+ else
+ say "#{source_uri} removed from sources"
+ end
elsif configured_sources
say "source #{source_uri} cannot be removed because it's not present in #{config_file_name}"
else
@@ -239,6 +243,10 @@ To remove a source use the --remove argument:
private
+ def default_sources
+ Gem::SourceList.from(Gem.default_sources)
+ end
+
def configured_sources
return @configured_sources if defined?(@configured_sources)