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

ruby-changes:72607

From: David <ko1@a...>
Date: Wed, 20 Jul 2022 19:55:45 +0900 (JST)
Subject: [ruby-changes:72607] fa5724cca9 (master): [rubygems/rubygems] Fix `ruby setup.rb --destdir /foo` modifying global specs

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

From fa5724cca97a22006c64bb382c3894e608c63c9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Sat, 16 Jul 2022 13:17:58 +0200
Subject: [rubygems/rubygems] Fix `ruby setup.rb --destdir /foo` modifying
 global specs

Running a command like that is actually removing any previous default
bundler specs in the default RubyGems installation (outside of destdir).
It should instead only modify destdir.

https://github.com/rubygems/rubygems/commit/5ed275383c
---
 lib/rubygems/commands/setup_command.rb           | 8 ++++----
 test/rubygems/test_gem_commands_setup_command.rb | 8 ++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index f85d435f58..db2fefa65e 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -361,17 +361,17 @@ By default, this RubyGems will install gem as: https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/setup_command.rb#L361
 
   def install_default_bundler_gem(bin_dir)
     current_default_spec = Gem::Specification.default_stubs.find {|s| s.name == "bundler" }
-    specs_dir = if current_default_spec
+    specs_dir = if current_default_spec && default_dir == Gem.default_dir
       Gem::Specification.remove_spec current_default_spec
       loaded_from = current_default_spec.loaded_from
       File.delete(loaded_from)
       File.dirname(loaded_from)
     else
-      File.join(default_dir, "specifications", "default")
+      target_specs_dir = File.join(default_dir, "specifications", "default")
+      mkdir_p target_specs_dir, :mode => 0755
+      target_specs_dir
     end
 
-    mkdir_p specs_dir, :mode => 0755
-
     bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
     default_spec_path = File.join(specs_dir, "#{bundler_spec.full_name}.gemspec")
     Gem.write_binary(default_spec_path, bundler_spec.to_ruby)
diff --git a/test/rubygems/test_gem_commands_setup_command.rb b/test/rubygems/test_gem_commands_setup_command.rb
index 161c88d683..aa5feb9074 100644
--- a/test/rubygems/test_gem_commands_setup_command.rb
+++ b/test/rubygems/test_gem_commands_setup_command.rb
@@ -279,6 +279,14 @@ class TestGemCommandsSetupCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_setup_command.rb#L279
 
     @cmd.install_default_bundler_gem bin_dir
 
+    # leaves other versions of bundler gemspecs on default specification directory.
+    assert_path_exist previous_bundler_specification_path
+    assert_path_not_exist new_bundler_specification_path
+
+    # installs the updated bundler gemspec to destdir
+    assert_path_not_exist prepend_destdir(destdir, previous_bundler_specification_path)
+    assert_path_exist prepend_destdir(destdir, new_bundler_specification_path)
+
     bundler_spec.executables.each do |e|
       assert_path_exist prepend_destdir(destdir, File.join(@gemhome, 'gems', bundler_spec.full_name, bundler_spec.bindir, e))
     end
-- 
cgit v1.2.1


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

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