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

ruby-changes:71995

From: David <ko1@a...>
Date: Sat, 28 May 2022 19:22:36 +0900 (JST)
Subject: [ruby-changes:71995] e78c1ddb1e (master): [rubygems/rubygems] Fix rubygems update when non default `--install-dir` is configured

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

From e78c1ddb1ed9b55550c13d0a7f1e84f62f987230 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 25 May 2022 13:33:20 +0200
Subject: [rubygems/rubygems] Fix rubygems update when non default
 `--install-dir` is configured

https://github.com/rubygems/rubygems/commit/9f3b21192d
---
 lib/rubygems/commands/update_command.rb           |  9 +++----
 test/rubygems/test_gem_commands_update_command.rb | 31 +++++++++++++++++++++++
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/lib/rubygems/commands/update_command.rb b/lib/rubygems/commands/update_command.rb
index 42d6f6046b..54b1251010 100644
--- a/lib/rubygems/commands/update_command.rb
+++ b/lib/rubygems/commands/update_command.rb
@@ -173,10 +173,11 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L173
     highest_remote_gem.first
   end
 
-  def install_rubygems(version) # :nodoc:
+  def install_rubygems(spec) # :nodoc:
     args = update_rubygems_arguments
+    version = spec.version
 
-    update_dir = File.join Gem.dir, 'gems', "rubygems-update-#{version}"
+    update_dir = File.join spec.base_dir, 'gems', "rubygems-update-#{version}"
 
     Dir.chdir update_dir do
       say "Installing RubyGems #{version}" unless options[:silent]
@@ -290,9 +291,7 @@ command to remove old versions. https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/update_command.rb#L291
     installed_gems = update_gem('rubygems-update', version) if installed_gems.empty? || installed_gems.first.version != version
     return if installed_gems.empty?
 
-    version = installed_gems.first.version
-
-    install_rubygems version
+    install_rubygems installed_gems.first
   end
 
   def update_rubygems_arguments # :nodoc:
diff --git a/test/rubygems/test_gem_commands_update_command.rb b/test/rubygems/test_gem_commands_update_command.rb
index c765e9a8df..b5e9f004d1 100644
--- a/test/rubygems/test_gem_commands_update_command.rb
+++ b/test/rubygems/test_gem_commands_update_command.rb
@@ -191,6 +191,37 @@ class TestGemCommandsUpdateCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_update_command.rb#L191
     assert_empty out
   end
 
+  def test_execute_system_update_installed_in_non_default_gem_path
+    rubygems_update_spec = quick_gem "rubygems-update", 9 do |s|
+      write_file File.join(@tempdir, 'setup.rb')
+
+      s.files += %w[setup.rb]
+    end
+
+    util_setup_spec_fetcher rubygems_update_spec
+
+    rubygems_update_package = Gem::Package.build rubygems_update_spec
+
+    gemhome2 = "#{@gemhome}2"
+
+    Gem::Installer.at(rubygems_update_package, :install_dir => gemhome2).install
+
+    Gem.use_paths @gemhome, [gemhome2, @gemhome]
+
+    @cmd.options[:args]          = []
+    @cmd.options[:system]        = true
+
+    use_ui @ui do
+      @cmd.execute
+    end
+
+    out = @ui.output.split "\n"
+    assert_equal "Installing RubyGems 9", out.shift
+    assert_equal "RubyGems system software updated", out.shift
+
+    assert_empty out
+  end
+
   def test_execute_system_specific
     spec_fetcher do |fetcher|
       fetcher.download 'rubygems-update', 8 do |s|
-- 
cgit v1.2.1


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

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